Automating the world one-liner at a time…
One of the coolest new features of Windows PowerShell is PowerShell modules. I've just written a tutorial about how to use them on my personal blog.
You can check out the full post for more details, but here are some easy things to remember about modules:
The module examples also include a few PowerShell functions you might use in day-to-day life, such as being able to Search-WindowsDesktop, Get-RecordedTV, or Remove-RecordedTVBySeries, and are a great practical example of how you can use modules to cleanly separate code. Check it out.
Hope this helps,
James Brundage [MSFT]
I just keep getting "The term 'Add-Module' is not recognized as a cmdlet..."
And yes, I do have CTP 2.0
Any ideas?
There's no Add-Module, atleast in CTP3...
PS> Get-Help *-module
New-Module
Import-Module
Get-Module
Remove-Module
I get this:
PS C:\> Import-Module
The term 'Import-Module' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and
try again.
At line:1 char:14
+ Import-Module <<<<
and PS> Get-Help *-module returns nothing...
Are there any hooks that I can use when loading/unloading a module?
For example - I would like to have a module that helps with communicating to MSSQL. It would be efficient if I could open the database connection once at load time, keep the same connection open for multiple DB queries and close/dispose of the connection nicely when I'm finished with it. It would also be good if it handled errors being thrown elsewhere in the script.