Skip to content

Windows PowerShell 5.1

Your Name edited this page Mar 29, 2026 · 7 revisions

Walkthrough Video

Below is a video walkthrough of the steps on this page:

OSDWorkspace Prerequisites: PowerShell 5.1

Quick Setup

Run all steps in sequence from an elevated (Run as Administrator) Windows PowerShell 5.1 session:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force

if ((Get-PackageProvider).Name -notcontains 'NuGet') {
    Install-PackageProvider -Name NuGet -Force
}

Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted

Install-Module -Name PowerShellGet    -Force -Scope AllUsers -AllowClobber -SkipPublisherCheck
Install-Module -Name PackageManagement -Force -Scope AllUsers -AllowClobber -SkipPublisherCheck

Important: All commands on this page must be run from an elevated Windows PowerShell 5.1 session (right-click > Run as Administrator). Do not use PowerShell 7 for these steps — the settings apply specifically to the Windows PowerShell 5.1 environment.


Step 1 — Set the Execution Policy

Windows PowerShell's default execution policy blocks scripts from running. Set it to RemoteSigned to allow locally authored scripts and signed remote scripts to execute:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force

To verify the policy was applied:

Get-ExecutionPolicy -List

The LocalMachine scope should show RemoteSigned.


Step 2 — Install the NuGet Package Provider

NuGet is required by PowerShellGet and PackageManagement to interact with the PowerShell Gallery. Install it if it is not already present:

if ((Get-PackageProvider).Name -notcontains 'NuGet') {
    Install-PackageProvider -Name NuGet -Force
}

To verify NuGet is available:

Get-PackageProvider -Name NuGet

Step 3 — Trust the PowerShell Gallery

By default, PSGallery is set to Untrusted, which causes confirmation prompts every time a module is installed. Set it to Trusted to allow unattended module installs:

Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted

To verify the repository trust level:

Get-PSRepository -Name 'PSGallery'

The InstallationPolicy should show Trusted.


Step 4 — Update PowerShellGet

The version of PowerShellGet shipped with Windows is outdated. Install the latest version from the PowerShell Gallery:

Install-Module -Name PowerShellGet -Force -Scope AllUsers -AllowClobber -SkipPublisherCheck

To verify the installed version:

Get-Module -Name PowerShellGet -ListAvailable | Select-Object Name, Version

Step 5 — Update PackageManagement

PackageManagement is updated as a dependency of PowerShellGet, but run this explicitly if you encounter module installation issues:

Install-Module -Name PackageManagement -Force -Scope AllUsers -AllowClobber -SkipPublisherCheck

To verify the installed version:

Get-Module -Name PackageManagement -ListAvailable | Select-Object Name, Version

Additional Resources

Clone this wiki locally