Lesson 7 of 13 · 14m
Two Editions, One Box
powershell.exe is frozen 5.1, pwsh.exe is current 7.x, and execution policy was never a security boundary.
There are two PowerShells, and they live side by side on the same Windows box pretending to be one product. powershell.exe is Windows PowerShell 5.1 — .NET Framework, shipped in-box since 2016, frozen. pwsh.exe is PowerShell 7 — .NET (formerly Core), installed separately, updated yearly: 7.4 landed November 2023 as the LTS, 7.5 followed in January 2025. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe will be 5.1 forever. Nothing upgrades it. Ever.
Which one just ran?
$PSVersionTable.PSEdition answers it: Desktop for 5.1, Core for 7. The trap is ambient defaults. Task Scheduler actions that say powershell.exe run 5.1. powershell typed in Run dialog, in cmd, or from another script's & powershell ... gets 5.1. File associations for .ps1 point at 5.1. VS Code's integrated terminal runs whichever profile you picked. So your automation can be on a different runtime than your editor was last week, and the only symptom is a cmdlet that "worked on my machine" failing in the scheduled task at 3 AM. Pin it explicitly: task actions should name pwsh.exe -File or powershell.exe -File — the path is a decision, not a default.
What actually differs
7.x isn't a reskin. ForEach-Object -Parallel exists only there. Ternary ?: and null-coalescing ??/??= exist only there. $PSNativeCommandUseErrorActionPreference (7.4+), PSStyle ANSI rendering, ConvertFrom-Json -AsHashtable, Test-Json, ConciseView errors, --% (that one's 5.1 too — the stop-parsing token). Microsoft.PowerShell.PSResourceGet replaces PowerShellGet v2 for module installs. And a pile of things only exist in 5.1: *-Transaction* cmdlets, the PSScheduledJob module (Register-ScheduledJob), Workflow, snapins (Add-PSSnapin), New-PSRoleCapabilityFile-era quirks aside — the big one people hit is any CDXML/CDM module that was never ported.
The compatibility shim covers most of the gap: on Windows, PS 7 can load inbox Windows PowerShell modules through the Windows PowerShell Compatibility feature — Import-Module -UseWindowsPowerShell, or implicitly for many modules in C:\Windows\System32\WindowsPowerShell\v1.0\Modules. It spins up a hidden 5.1 process and proxies the module through remoting. It works until it doesn't — the proxy adds serialization exactly like the last lesson, using: module behaviors get weird, and some modules (the WSUS UpdateServices module being the famous example) are on the no-compat list and only run in a real 5.1. Check Get-Module -ListAvailable under both hosts before you bet a migration on it.
Execution policy is not a wall
Get-ExecutionPolicy returns Restricted, RemoteSigned, AllSigned, or Unrestricted, and somewhere along the way teams started believing this was a security boundary. Microsoft's own documentation says it isn't. -ExecutionPolicy Bypass is a per-process switch: powershell.exe -ep bypass -File x.ps1. Get-Content x.ps1 | powershell - pipes the script through stdin where no policy applies. -EncodedCommand wraps the whole thing in base64 that looks harmless in logs. An unsigned-script policy never stopped a determined user and wasn't designed to — it's a consent mechanism against accidental execution, like the zone tag on a downloaded file. The actual guardrails are AMSI (which scans script content in memory regardless of where it launched), AppLocker/WDAC signing enforcement, and Script Block Logging watching Microsoft-Windows-PowerShell/Operational for events 4103/4104. If your controls list says "we require RemoteSigned so we're covered," you're covered against precisely nothing.
Cross-edition remoting
Invoke-Command between editions is fine — a 7 client can hit a 5.1 endpoint and vice versa; the wire protocol is the same. What's different in 7 is the second transport: -HostName plus SSH. Configure sshd with Subsystem powershell /usr/bin/pwsh -sshs -nologo (path varies by distro) and Enter-PSSession -HostName ubuntu01 -UserName ops works like WinRM — that's how Linux boxes enter the automation estate, and how Windows boxes join it where WinRM is politically or technically unwelcome. -ConfigurationName picks the endpoint either way.
The practice
Pick the edition per workload, write it down, and pin every entry point — scheduled task actions, CI agents, runbooks — to the literal binary. Audit scripts under both before migrating: the 5.1-only cmdlets are the ones that will surprise you (transactions, PSScheduledJob, snapins, WSUS). Keep powershell.exe around for the modules that need it; pwsh for everything you're writing now. And stop treating execution policy as a control — log 4104s, deploy AppLocker, and let Bypass be what it is: a convenience flag attackers were never going to respect anyway.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A Fake GTA 6 ISO Didn’t Install a Game. It Installed a Wiper.
A fake GTA 6 ISO used a believable installer error to cover remote-access malware, browser-data theft, and destructive file wiping. The “License not found” message wasn’t the crack failing. It was there so the victim would stop looking.
BlueHammer: The Unpatched Windows Zero-Day That Weaponizes Microsoft Defender Against Your Own System
BlueHammer is an unpatched, publicly released Windows local privilege escalation exploit that chains Microsoft Defender's update workflow, Volume Shadow Copy, Cloud Files callbacks, and opportunistic locks to reach NT AUTHORITY\SYSTEM from a standard user account.
Running a Minecraft Network: Four JVMs, One Box, and the Settings That Lie to You
Four servers on one host means four JVMs each sizing its thread pools for a machine it does not own. The measured cost of that, the systemd ordering that guarantees nothing, and the throttle that switches itself back on when your forwarding breaks.
Building a Minecraft Network: Four Servers Pretending to Be One Place
A proxy, a lobby, an SMP and a PvP arena is four JVMs that know nothing about each other. What actually has to be shared, why your permissions don't follow players, and the two LuckPerms defaults that silently share nothing at all.