-
Notifications
You must be signed in to change notification settings - Fork 7
Windows PowerShell 5.1
Below is a video walkthrough of the steps on this page:
OSDWorkspace Prerequisites: PowerShell 5.1
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 -SkipPublisherCheckImportant: 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.
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 -ForceTo verify the policy was applied:
Get-ExecutionPolicy -ListThe LocalMachine scope should show RemoteSigned.
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 NuGetBy 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 TrustedTo verify the repository trust level:
Get-PSRepository -Name 'PSGallery'The InstallationPolicy should show Trusted.
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 -SkipPublisherCheckTo verify the installed version:
Get-Module -Name PowerShellGet -ListAvailable | Select-Object Name, VersionPackageManagement 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 -SkipPublisherCheckTo verify the installed version:
Get-Module -Name PackageManagement -ListAvailable | Select-Object Name, Version