by oising
16. December 2011 11:47
I’m seeing a few errant companies have their installers throw their modules into ${env:systemroot}\WindowsPowerShell\1.0\Modules but this is not the right place. The only things that should go there are core operating system modules from Microsoft. So, where should you install them?
How to: Install a module for all users
- Create the folder ${env:programfiles}\YourProduct\PowerShell\Modules\
- Place your module (or modules) under this folder
- Add the folder from step 1 to the system scoped environment variable PSModulePath; consider embedding %ProgramFiles% to keep the environment string as short as possible
- Profit.
How to: Install a module for the current user
- Test for, and create if necessary the folder which is the result of this call (or equivalent in managed code): join-path ([environment]::GetFolderPath("MyDocuments")) WindowsPowerShell\Modules
- Copy your module or (modules) to folder at above
- Profit.
It’s as easy as that.