So you’re starting to get the hang of this PowerShell stuff and are able to pull off your own fancy tricks with the builtin cmdlets, but you need more! You want to be able to do things like create computer accounts, get VMware host information or turn on Cisco UCS and HP blades, cool stuff! Well, there is a way and that way is PowerShell modules.
PowerShell modules come in two types, script modules (.psm1 files) and binary dll files. Not long from now you will be creating your own modules but if you would like to get a head start on that I suggest the MSDN topic, it has everything you ever wanted to know on modules.
To start out you are going to need to download some modules from your favourite vendor, Microsoft with the RSAT toolkit, F5, EMC, Cisco, HP and VMware all have module packs available and ready to download on their website. To give you an idea on how easy it is to work with modules please give this little exercise a try:
- Download the Windows RSAT for your OS
- Install the RSAT
- Launch a new, normal PowerShell window
- Run the command Import-Module ActiveDirectory
- Now have a look at all the shiny new cmdlets using Get-Command -Module ActiveDirectory
Now if you want to use some of the vendor cmdlets they require “snapins” instead of modules. The process is largely the same though, e.g. *Add-PSSnapin VMware**.
To further enhance this new found ability, have a think about how you would tackle the following:
- How would you make these new cmdlets available in your scripts?
- Got a favourite module that you would like to load every session? How would you modify your profile to accomplish this?
- Take that thought a step further, how would you add ALL your modules each time?