Windows PowerShell 5.1 - OSDeploy/OSD.Workspace GitHub Wiki

Set the Execution Policy to RemoteSigned

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

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force

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
}

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."
}

Update PowerShellGet

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

Update PackageManagement

This should have been updated as part of PowerShellGet, but if you encounter issues, you can run the following command to ensure it is up to date:

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