$PSVersionTable Expected output snippet:

Write-Host "Installing PowerShell 5.1..." -ForegroundColor Cyan Start-Process wusa.exe -ArgumentList "$msu /quiet /norestart" -Wait

wusa.exe "C:\path\to\Win8.1AndW2K12R2-KB3191564-x64.msu" /quiet /norestart For automatic reboot:

$PSVersionTable.PSVersion If the output shows Major 5 and Minor 1 , you already have it. Otherwise, proceed.