April 02, 2015

Simplified module loading in powershell

There is a feature for automatic module discorvery in Powershell. It can search for modules based on paths from PsModulePath variable. It is easy to modify it in a script:

$env:PsModulePath += ";$PsScriptRoot/Modules"

Import-Module SomeModule -ArgumentList "foo" -Verbose // no need to specify path to the module

Get-OtherModuleThing // module will be loaded automatically