PowerShell for Windows Admins

Mar 21 2019   11:16AM GMT

Install-Module Scope parameter

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: