An Introduction to PowerShell Modules
-
Upload
jonathanmedd -
Category
Technology
-
view
7 -
download
1
description
Transcript of An Introduction to PowerShell Modules
An Introduction to PowerShell Modules
Jonathan Medd
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
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
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
Modules can transform you from this:
To Superstars with Groupies:
More on the module that made that transformation happen later........
Buy This Book
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
Demo – Create a Module
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
Demo – Create The Manifest
Modules Make Distributing Your Code Easier
VS
Demo – PowerCLIBook Module
Other ModulesWindows Server2008 R2 -
>Community Modules
PowerShell Community Extensions
BSonPOSH ModuleSQLPSX
Search on http://www.codeplex.com – currently 50+
Demo – TroubleShootingPack Module
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