Monthly Archive

Categories

Install-Module Scope parameter

Be aware of the Scope parameter when using Install-Module. The following rules apply:

Allusers scope installs to $env:ProgramFiles\PowerShell\Modules

CurrentUser scope installs to $home\Documents\PowerShell\Modules

NoScope defined:

- - For an elevated PowerShell session, Scope defaults to AllUsers

- - For non-elevated PowerShell sessions in PowerShellGet versions 2.0.0 and above, the Scope is CurrentUser

- - For non-elevated PowerShell sessions in PowerShellGet versions 1.6.7 and earlier, Scope is undefined, and Install-Module fails

 

PowerShell v6.2 RC 1 uses PowerShellGet 2.0.4 and PowerShell v6.1.3 uses version 1.6.7. You’ll see different behavior depending on PowerShell version so the advice is to use the Scope parameter to ensure the module goes where you intend.

 

I usually want my modules in Program files (Allusers) rather than my documents folder (CurrentUser).

 

The lesson seems to be to use the Scope parameter rather than relying on defaults

Comments are closed.