OSDeploy PSModule and site pages are currently in preview until mid-September
For the complete documentation index, see llms.txt. This page is also available as Markdown.

PowerShell 7

Install PowerShell 7.6 or later from the MSI package required by OSDeploy.

Install the latest stable PowerShell 7 MSI package on the OSDeploy PC. PowerShell 7 installs side by side with Windows PowerShell 5.1 and runs from $env:ProgramFiles\PowerShell\7 by using pwsh.

Install PowerShell

1

Confirm the Requirements

Run these steps on a prepared Windows 11 OSDeploy PC with Internet access. Open Windows PowerShell as an administrator.

2

Download the Latest MSI

Run this script to detect the OSDeploy PC architecture and download the matching MSI package from the latest stable PowerShell release:

$Release = Invoke-RestMethod -Uri 'https://api.github.com/repos/PowerShell/PowerShell/releases/latest'
$Version = $Release.tag_name.TrimStart('v')
$Architecture = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
$MsiFileName = "PowerShell-$Version-win-$Architecture.msi"
$DownloadFolder = Join-Path $env:ProgramData 'OSDeployCore\software\Microsoft.PowerShell'
$MsiPath = Join-Path $DownloadFolder $MsiFileName

New-Item -Path $DownloadFolder -ItemType Directory -Force | Out-Null

$Asset = $Release.assets | Where-Object name -EQ $MsiFileName
if (-not $Asset) {
	throw "The $MsiFileName asset was not found in the latest stable PowerShell release."
}

curl.exe -L -o $MsiPath $Asset.browser_download_url
3

Install the MSI

Silently install PowerShell with the recommended options from Microsoft:

$MsiParameters = @(
	"/package `"$MsiPath`""
	'/quiet'
	'/norestart'
	'ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1'
	'ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1'
	'ENABLE_PSREMOTING=1'
	'REGISTER_MANIFEST=1'
	'USE_MU=1'
	'ENABLE_MU=1'
	'ADD_PATH=1'
)

& msiexec.exe $MsiParameters
if ($LASTEXITCODE -notin 0, 3010) {
	throw "PowerShell MSI installation failed with exit code $LASTEXITCODE."
}

See Install the MSI package with command-line options for details about these installer properties.

4

Open PowerShell 7

Exit Windows PowerShell, open a new PowerShell 7 session by running pwsh, and inspect the installed version and location:

$PSVersionTable | Select-Object PSEdition, PSVersion
$PSHOME

The output must report Core, PowerShell 7.6 or later, and a $PSHOME under $env:ProgramFiles\PowerShell\7. Restart Windows first if msiexec.exe returned exit code 3010.

Continue to Install PowerShell Modules.

Last updated

Was this helpful?