an introduction to powershell modules
DESCRIPTION
An Introduction to PowerShell ModulesTRANSCRIPT
![Page 1: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/1.jpg)
An Introduction to PowerShell Modules
Jonathan Medd
![Page 2: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/2.jpg)
How can you distribute additional PowerShell functionality?Snapin – PowerShell v1
Provider or CmdletsNot for your average IT Pro to create
Module – PowerShell v2 (Snapins still available)Provider, Cmdlets, Functions, Variables and
AliasesAny IT Pro can make a module
![Page 3: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/3.jpg)
What is a module?Simple as a collection of files containing
functions, scripts etc and possibly other files such as the manifest to make it more professional
Stored within a folder as a subfolder of the Modules location. Can be found via $env:PSModulePath
Contents made accessible to the user via the Import-Module cmdlet
![Page 4: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/4.jpg)
Why bother?Makes sharing of groups of functions and
scripts easySimple XCOPY style deployment of the
module folder either internally or publishing to an external website
Make your commonly used functions available to yourself without ‘Profile Bloat’ – they are available as and when you need them from a module
![Page 5: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/5.jpg)
Modules can transform you from this:
![Page 6: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/6.jpg)
To Superstars with Groupies:
![Page 7: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/7.jpg)
More on the module that made that transformation happen later........
![Page 8: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/8.jpg)
Buy This Book
![Page 9: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/9.jpg)
Making Your First ModuleCreate two functionsSave them into a *.psm1 file to the module
folderImport them for use into your sessionGo!
Yes it is as easy as that
![Page 10: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/10.jpg)
Demo – Create a Module
![Page 11: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/11.jpg)
Making Your Module More ProfessionalCreate a Module Manifest using New-ModuleManifestInclude Authoring or Version infoSpecify minimum versions of PowerShell
or .NET required for the moduleNest other modulesRun scripts prior to loading the module, e.g.
check for third-party snapin dependenciesCan be created manually Use Test-ModuleManifest to check for
issues
![Page 12: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/12.jpg)
Demo – Create The Manifest
![Page 13: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/13.jpg)
Modules Make Distributing Your Code Easier
VS
![Page 14: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/14.jpg)
Demo – PowerCLIBook Module
![Page 15: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/15.jpg)
Other ModulesWindows Server2008 R2 -
>Community Modules
PowerShell Community Extensions
BSonPOSH ModuleSQLPSX
Search on http://www.codeplex.com – currently 50+
![Page 16: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/16.jpg)
Demo – TroubleShootingPack Module
![Page 17: An Introduction to PowerShell Modules](https://reader035.vdocuments.us/reader035/viewer/2022062613/5455a42baf7959664b8b4ca2/html5/thumbnails/17.jpg)
Wrap UpGet-Help about_Moduleshttp://www.simple-talk.com/sysadmin/powers
hell/an-introduction-to-powershell-modules/http://blogs.technet.com/b/heyscriptingguy/ar
chive/2010/01/18/hey-scripting-guy-january-18-2010.aspx