An Introduction to PowerShell Modules

2,177 views

Published on

An Introduction to PowerShell Modules

Published in: Technology, Art & Photos
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,177
On SlideShare
0
From Embeds
0
Number of Embeds
625
Actions
Shares
0
Downloads
34
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

An Introduction to PowerShell Modules

  1. 1. An Introduction to PowerShell Modules<br />Jonathan Medd<br />
  2. 2. How can you distribute additional PowerShell functionality?<br />Snapin – PowerShell v1<br />Provider or Cmdlets<br />Not for your average IT Pro to create<br />Module – PowerShell v2 (Snapins still available)<br />Provider, Cmdlets, Functions, Variables and Aliases<br />Any IT Pro can make a module<br />
  3. 3. What is a module?<br />Simple as a collection of files containing functions, scripts etc and possibly other files such as the manifest to make it more professional<br />Stored within a folder as a subfolder of the Modules location. Can be found via $env:PSModulePath<br />Contents made accessible to the user via the Import-Module cmdlet<br />
  4. 4. Why bother?<br />Makes sharing of groups of functions and scripts easy<br />Simple XCOPY style deployment of the module folder either internally or publishing to an external website<br />Make your commonly used functions available to yourself without ‘Profile Bloat’ – they are available as and when you need them from a module<br />
  5. 5. Modules can transform you from this:<br />
  6. 6. To Superstars with Groupies:<br />
  7. 7. More on the module that made that transformation happen later........<br />
  8. 8. Buy This Book <br />
  9. 9. Making Your First Module<br />Create two functions<br />Save them into a *.psm1 file to the module folder<br />Import them for use into your session<br />Go!<br />Yes it is as easy as that <br />
  10. 10. Demo – Create a Module<br />
  11. 11. Making Your Module More Professional<br />Create a Module Manifest using New-ModuleManifest<br />Include Authoring or Version info<br />Specify minimum versions of PowerShell or .NET required for the module<br />Nest other modules<br />Run scripts prior to loading the module, e.g. check for third-party snapin dependencies<br />Can be created manually <br />Use Test-ModuleManifest to check for issues<br />
  12. 12. Demo – Create The Manifest<br />
  13. 13. Modules Make Distributing Your Code Easier<br />VS<br />
  14. 14. Demo – PowerCLIBook Module <br />
  15. 15. Other Modules<br />Windows Server2008 R2 -><br />Community Modules<br />PowerShell Community Extensions<br />BSonPOSH Module<br />SQLPSX<br />Search on http://www.codeplex.com – currently 50+<br />
  16. 16. Demo – TroubleShootingPack Module<br />
  17. 17. Wrap Up<br />Get-Help about_Modules<br />http://www.simple-talk.com/sysadmin/powershell/an-introduction-to-powershell-modules/<br />http://blogs.technet.com/b/heyscriptingguy/archive/2010/01/18/hey-scripting-guy-january-18-2010.aspx<br />

×