Learn about Windows PowerShell
Summary: Learn how to find and import Windows PowerShell modules.
I want to get a list of all the modules that are installed with Windows PowerShell on my machine. How can you do this?
Inside a Windows PowerShell console, type the following command:
Get-Module -ListAvailable
I want to load all of the modules that are installed with Windows PowerShell on my machine. How can you do this?
Get-Module –ListAvailable | import-module
Hi Ed,
you can also import dynamic modules:
PS II> New-Module -Name DynamicModule -Script {
function hello { b $args[0] }
function b($name) { write "hello $name" }
} -function hello | Import-Module -PassThru -Verbose
PS II> hello $env:USERNAME
@Walid Toumi that is a great tip thank you for sharing it. Let me ask you, how would you use a dynamic module? When does it make sense to you to do this?
@Ed
1- i use "New-Module" with "AsCustomObject" parameter to convert my dynamic modules into objects members and make their use simple
PS II>
$objMod=New-Module -Name DynamicModule -Script {
} -function hello | Import-Module -PassThru -Verbose -AsCustomObject
PS II> $objMod.hello("$env:username")
2- i use "New-Module" because is in memory not in disk and much easier to quickly group functions in memory and make them as a unit
(sorry for my english)
basic but essential