0
votes

I used the variable $Env:PSModulePath , It provided two paths.

> C:\Users\My User\Documents\WindowsPowerShell\Modules
> C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

Seems like My User will be accessible only for me. But my module will be used by multiple person and also when uninstalling my application [I am installing my module via msi], even if some other user uninstalls it should be removed.

Can I use "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\" for my application related module? Or is there any other better place ?

2

2 Answers

2
votes

Can i use "C:\Windows\system32\WindowsPowerShell\v1.0\Modules\" for my application related module?

No. That place is not for you as noted in the section "Rules for Installing Modules" of the module installation guidelines.

You can decide yourself where you want to put the modules that are shared for multiple users.

Some options include:

  • Create new folder in Program Files, and add that path to PSModulePath.
  • Use a network share (though this means you need to change your execution policy to allow this), as @Rubanov said.
  • Use the All Users folder for example.
1
votes

You can also put your psm1 files on a shared drive. Then import the module with

Import-Module -Name "\\SERVERNAME\Use-MyModule.psm1"

You can find more info about adding a path to PSModulePath here.