Windows Server 2022 and 2025 still ship with Windows PowerShell 5.1, but Microsoft has been building the language forward in PowerShell 7 (the pwsh executable, based on .NET) for years. You can run both side by side on the same server, and most small VPS fleets should. The question is which engine your scripts, scheduled tasks and modules should target – and what quietly breaks when you switch.
The engine difference in one paragraph
Windows PowerShell 5.1 runs on .NET Framework and is Windows-only. PowerShell 7 runs on modern .NET, is cross-platform, and is where new language features land. On Windows Server, powershell.exe and pwsh.exe coexist without conflict: different binaries, different module paths, same registry-based execution policy. Installing 7 does not replace 5.1.
What you gain in PowerShell 7
- Parallel loops:
ForEach-Object -Parallelwith-ThrottleLimitcollapses a whole class of slow fan-out scripts. - Modern operators: ternary (
$x = $ok ? 1 : 0), null-coalescing (??and??=), and pipeline chaining with&&/||. - Better web cmdlets:
Invoke-RestMethodandInvoke-WebRequestdefault to basic parsing and handle JSON much more sanely (ConvertFrom-Json -AsHashtable, configurable depth). - Faster, more modern runtime with improved error messages, PSReadLine 2 editing, and a genuinely maintained
Update-Help.
# Parallel example: check 50 hosts for a port
$hosts = Get-Content servers.txt
$hosts | ForEach-Object -Parallel {
Test-NetConnection -ComputerName $_ -Port 443 -InformationLevel Quiet
} -ThrottleLimit 10
What breaks when you switch
Get-WmiObjectis gone. It does not exist in PowerShell 7. Replace withGet-CimInstance– most scripts need only a find-and-replace, but output types differ and some parameters behave differently.- Module compatibility is the real gate. Core Windows modules (
NetSecurity,NetAdapter,DnsClient,IISAdministration,Storage) load fine in 7 on Windows. Some older ones –ServerManager, various third-party snap-ins built against .NET Framework – do not. Always test withImport-Modulebefore rewriting a scheduled task. - GUI-bound cmdlets are Windows-only.
Out-GridViewworks inpwshon Windows but not on Linux or macOS; anything that shells out topowershell.exe(COM, legacy snap-ins) must stay in 5.1. - Object shape differences.
Invoke-WebRequestreturns a different response object in 7 –.Contentstill exists, but scripts that reach into.Headersor rely on.StatusCodeshould be re-tested. - Scheduled tasks and wrappers. A task that calls
powershell.exe -File script.ps1keeps running 5.1 no matter what you install. Update the action topwsh.exedeliberately, per task.
Installing PowerShell 7 on Windows Server
winget install --id Microsoft.PowerShell --source winget
# or download the MSI from the official releases page
pwsh --version
Both engines read the same registry-based execution policy on Windows, so a policy you set for one applies to the other. Check the edition inside any script that might run under either engine:
if ($PSVersionTable.PSEdition -ne "Core") {
Write-Warning "This script is designed for PowerShell 7"
exit 1
}
The compatibility shim for stubborn modules
PowerShell 7 includes a Windows PowerShell compatibility mechanism: Import-Module -UseWindowsPowerShell loads a 5.1 module in a background Windows PowerShell process and proxies its cmdlets into your pwsh session. It is not a silver bullet – there is proxy overhead, and some cmdlets that return live objects behave oddly through the proxy – but it keeps ServerManager-class modules usable while you migrate the rest of the estate:
Import-Module ServerManager -UseWindowsPowerShell
Get-WindowsFeature Web-Server | Select-Object Name, Installed
Migration gotchas worth planning for
- DSC resources. Many classic Desired State Configuration resources still assume 5.1. Test each configuration under 7 before scheduling it; the error messages are not always obvious.
- Help and docs.
Update-Helpruns per engine. After installing 7, runUpdate-Help -Forceinpwshonce so offline help matches the new engine. - CIM sessions.
New-CimSession -ComputerNamedepends on WinRM, which behaves identically in both engines – but if your old scripts usedGet-WmiObject -ComputerName, the parameter names differ and the rewrite is not always a one-for-one swap. - Profile files. 5.1 and 7 read different profile paths (
Documents\WindowsPowerShellvsDocuments\PowerShell). Aliases and functions you rely on interactively must be duplicated or symlinked, or your interactive session will silently lose them.
Which engine for which job?
| Workload | Recommended engine | Why |
|---|---|---|
| New automation and CI/CD scripts | PowerShell 7 | Modern syntax, parallel loops, active development |
| Legacy scripts using WMI or COM | 5.1 (or migrate) | Get-WmiObject and COM interop behave as written |
| Modules not yet PS7-compatible | 5.1 | Import-Module test will tell you immediately |
| Scheduled maintenance tasks | 7 (pwsh.exe) | Pin the executable in the task action explicitly |
| Interactive admin shell | 7 | PSReadLine, better errors, tab completion |
The pragmatic path for a small server fleet: install 7, migrate new scripts to it, and keep 5.1 around purely as a compatibility shim for the handful of modules that have not caught up. Before you commit a workload to either engine, make sure the underlying hardware is right – the feature checklist on our site lists the resources to look for, and the Windows VPS comparison table on our site makes it easy to compare what different providers actually allocate to a Windows box.
