Skip to content

Windows PowerShell 5.1

David Segura - PowerShell MVP edited this page May 16, 2025 · 7 revisions

How to Configure Windows PowerShell 5.1

This guide provides step-by-step instructions to configure Windows PowerShell 5.1 for use with OSDWorkspace and the PowerShell Gallery. Follow these steps to ensure your environment is ready for module installation and management.

1. Set the Execution Policy

Set the execution policy to allow running local and remote scripts:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force

2. Install the NuGet Package Provider

NuGet is required for interacting with the PowerShell Gallery and managing modules. Install it if not already present:

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

3. Trust the PowerShell Gallery

Set the PowerShell Gallery (PSGallery) as a trusted repository to avoid confirmation prompts during module installation:

if ((Get-PSRepository -Name 'PSGallery').InstallationPolicy -ne 'Trusted') {
    Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
    Write-Host "PowerShell Gallery (PSGallery) has been set to Trusted."
} else {
    Write-Host "PowerShell Gallery (PSGallery) is already Trusted."
}

4. Install or Update Required Modules

Install or update the following modules to ensure compatibility and access to the latest features:

PowerShellGet

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

PackageManagement

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

Note:

  • Run PowerShell as Administrator for all steps above.
  • These steps are required for OSDWorkspace and other advanced module management scenarios.

Clone this wiki locally