m.miloch.dev ← Notes
Application Packaging

Windows PowerShell 5.1 Is Deprecated — What KB5137172 Means for PSADT, ConfigMgr and Intune Scripts

KB5137172 (November 17, 2026) deprecates Windows PowerShell 5.1: still supported, no removal date, last enabled by default in Windows Server 2025 and Windows 11 26H2. What the KB, the PowerShell team, the open MSIX tracking issue and the Intune, ConfigMgr and PSADT documentation say about deployment scripts, with an inventory script and a staged plan.

22 min read

On November 17, 2026, Microsoft published KB5137172 — Windows PowerShell 5.1 Deprecation. The article declares Windows PowerShell 5.1 deprecated and no longer in active development, while stating that it is still part of Windows, still supported and still serviced with security updates according to the lifecycle of each Windows version. Windows Server 2025 and Windows 11, version 26H2 are named as the last Windows versions that include 5.1 enabled by default. In the next Windows version, 5.1 becomes a Feature on Demand that is enabled by default on new installations. Removal is announced for a future version of Windows, without a date.

On the same day the PowerShell team announced in PowerShell 7 is coming to Windows that PowerShell 7 will be included beginning with the next release of Windows, delivered as an MSIX package. The team lists three open gaps of that package, the first of which is running as the SYSTEM account. The status of each gap is tracked in the open GitHub issue PowerShell #27565, which names Intune and ConfigMgr scripts explicitly. One week earlier, on 2026-11-10, PowerShell 7.4 and 7.5 reached end of support and PowerShell 7.7 shipped without an MSI package. This article sets out what the documentation says for deployment scripts in Intune, Configuration Manager and PSAppDeployToolkit (PSADT) 4, what does not run under pwsh today, how to inventory an estate, and a staged plan that changes nothing that works.

What KB5137172 Says

The KB is short, and most of its sentences matter for planning. The summary reads: "Windows PowerShell 5.1 is deprecated. It's no longer in active development. Windows PowerShell 5.1 is still part of Windows, and it's still supported." On removal: "Windows PowerShell 5.1 will be removed from a future version of Windows. Timing will be based on usage data and communicated in advance."

The timeline section has three entries:

KB timeline entryWording in KB5137172
2026Windows PowerShell 5.1 is deprecated. Windows Server 2025 and Windows 11, version 26H2 are the last versions of Windows to include PowerShell 5.1 enabled by default.
Next Version of WindowsWindows PowerShell 5.1 will be available as a Feature on Demand (FOD), enabled by default on new Windows installs.
Future Version of WindowsNot available.

The FAQ answers the operational question directly: "No change is required right now. Scripts and tools that rely on Windows PowerShell 5.1 can continue to run." Security updates continue "according to the Windows lifecycle. Support for Windows PowerShell is tied to the version of Windows you use." The PowerShell Support Lifecycle page states the same rule from the other side: Windows PowerShell is a component of the operating system and is subject to the Windows support lifecycle, not to the PowerShell 7 lifecycle.

Three details of the KB are worth recording without interpretation:

  • The Applies to list names only Windows 11 Home and Pro, versions 24H2, 25H2 and 26H2. Enterprise, Education and Windows Server editions are not listed, although the timeline text names Windows Server 2025. The KB gives no reason.
  • The FOD entry for the next version says "enabled by default on new Windows installs". The KB says nothing about devices that reach the next version by in-place upgrade.
  • The KB says it will be updated "as more information becomes available". It contains no removal date, no FOD capability name and no PowerShell 7 version number.

For finding dependencies, the KB names launch-path and in-script checks: powershell.exe runs Windows PowerShell 5.1, pwsh.exe runs PowerShell 7 or later, $PSVersionTable.PSEdition returns Desktop for 5.1 and Core for 7, and scripts may declare #Requires -Version 5.1 or #Requires -PSEdition Desktop. Its Take action list asks administrators to look for "scripts, scheduled tasks, installers, management agents, and tools that start powershell.exe or load Windows PowerShell modules".

A related KB from earlier in the month, KB5134574 (November 3, 2026), renames the Start menu labels to Windows PowerShell 5.1 and Windows PowerShell ISE 5.1 with the October 2026 preview and November 2026 security updates. It states that "Windows PowerShell stays in its existing location". Command lines that call %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe are not affected by the renaming.

Note
For reference only, not as a forecast: KB5065506 records that Windows PowerShell 2.0 was deprecated in 2017 and removed starting with an August 2025 release of Windows 11, version 24H2 and a September 2025 release of Windows Server 2025. KB5137172 sets no comparable date for 5.1.

What the PowerShell Team Adds

The PowerShell team blog post by Jason Helmick (November 17, 2026) adds the delivery model and the known gaps. On existing scripts it says: "PowerShell 7 is designed to be used side by side with Windows PowerShell 5.1. Your existing automation needs no changes." On delivery: "PowerShell 7 is delivered as an MSIX package. MSIX still needs work to match some things that worked with the MSI installer." The gaps named in the post are:

  • running as the SYSTEM account, "which affects scheduled tasks, services, device-management scripts, and remoting"
  • support for the DISM cmdlets, such as Add-WindowsCapability
  • support for machine-wide settings, such as the all-users profile

The post announces investment in community tools, documentation and PSScriptAnalyzer compatibility checks for inventory and analysis, to be shared "as it's ready", and an Inbox Working Group for triage. In replies to comments under the post, the author states that the change is "forward only": "Earlier versions, including 26H2, keep Windows PowerShell 5.1". A second reply states that the Windows PowerShell ISE is built for 5.1, does not switch to PowerShell 7, and that using the ISE with PowerShell 7 is not supported.

Neither the KB nor the blog post names the PowerShell 7 version that will ship in Windows, whether it will be an LTS or an STS release, or which channel will service it. Plans should not assume any of these.

Windows Server 2028 Preview: Deprecated, Available Side by Side

The Windows Server documentation reaches the same point from the server side. The Windows Server 2028 (Preview) tab of Features removed or no longer developed in Windows Server (updated 2026-11-20) contains the line "Windows Server 2028 deprecates Windows PowerShell 5.1" and asks administrators to test scripts, modules and management workflows with PowerShell 7. What's new in Windows Server 2028 Preview (updated 2026-11-19) lists PowerShell 7 as included from Insider Preview build 29706 and adds: "Windows PowerShell 5.1 remains available side by side, so existing automation can continue to use it without a forced migration."

The two statements do not contradict each other. The same Learn page defines a deprecated component as one that "still ships in Windows Server, is supported for production deployments, and continues to receive security and quality updates per the product lifecycle", and the preview tab carries the caveat that "the deprecation plans can change before release". The wider Server 2028 picture for ConfigMgr estates is covered in What Windows Server 2028 Means for ConfigMgr and Endpoint Teams.

The Open MSIX Gaps That Matter to Deployment Agents

Issue #27565 Tracking: MSIX packaging gaps for PowerShell 7 was opened on 2026-06-05 by Jason Helmick and is open as of 2026-11-26. It is an engineering tracking issue in a public repository, not a release commitment. The status update posted to the issue on 2026-11-11 states that it supersedes the status table in the issue description, that several gaps "have to be fixed in Windows itself, not in PowerShell", and that "We have no release timing to share."

Gap (issue)Effect described in the issueStatus, 2026-11-11 update
SYSTEM / LocalSystem context (#27562)pwsh cannot be located or invoked by SYSTEM, LocalSystem or service identities. Covers scheduled tasks as SYSTEM, Windows services, MDM scripts (Intune/ConfigMgr) and deployment agents. Marked as blocker.In progress
WinRM / PowerShell remoting (#27563)The WinRM plugin has ACL and registration requirements incompatible with per-user MSIX. Marked as blocker.Under investigation
DISM cmdlets (#13866)Add-WindowsCapability, Get-WindowsOptionalFeature and related cmdlets fail with "Class not registered". Marked as blocker. The fix has to be made in the Windows DISM component.Under review
Per-machine data store (#27697)$PSHome is read-only under MSIX; machine-wide configuration has no writable location.Under design
Session configuration .pssc (#9278)Register-PSSessionConfiguration writes to $PSHome\SessionConfig.Under investigation
All-users profile (#27564)Administrators cannot write $PROFILE.AllUsersAllHosts.Under investigation
Update-Help -Scope AllUsers (#27699)Fails because $PSHome is read-only.Not started
Export effective configuration (#27698)Requested cmdlet for the merged configuration.Not started
Server Core MSIX activation (#27610)MSIX packages cannot register or activate on Server Core.In progress
.ps1 file association (#27277), silent write error (#25733)Minor gaps.Not on critical path

Issue #27562 describes the failure with a reproduction from an elevated prompt: psexec -s -i pwsh.exe returns "The system cannot find the file specified." The issue calls this "a known architectural constraint of MSIX packaging" and a blocker for the inboxing initiative. The 2026-11-11 update adds that "Windows platform work to make MSIX-packaged PowerShell available to the SYSTEM account is under way", and that running as SYSTEM in services and scheduled tasks will be tested once that work is stable.

The issue description ends with the sentence "We are committed to resolving the blocker gaps before PS7 ships as the inbox shell." This is the team's own statement in an open issue, without a date. It should be read as intent, not as a dated product commitment, and a deployment design should not depend on it until the issue reports the gap as resolved in a released build.

The consequence for deployment engineering is narrow and concrete. Several documented execution paths run as SYSTEM: Intune Win32 apps with the install behaviour System, Intune platform scripts with Run this script using the logged on credentials set to No, and the ConfigMgr Run PowerShell Script step unless another account is specified, since that step's option is described as running the script "as a Windows user account other than the Local System account". An MSIX-delivered pwsh that SYSTEM cannot find is not a usable script host on these paths today, regardless of whether a given script would be compatible with PowerShell 7.

PowerShell 7 Packages and Lifecycle in November 2026

Packagers who already deploy PowerShell 7 as an application face a separate set of facts that changed on 2026-11-10.

ReleaseStatus per Microsoft sourcesWindows packagesEnd of support
PowerShell 7.4 (LTS, .NET 8)Out of supportMSI, ZIP, MSIX2026-11-10
PowerShell 7.5 (.NET 9)Out of supportMSI, ZIP, MSIX2026-11-10
PowerShell 7.6 (LTS, .NET 10)Current LTS; 7.6.10 released 2026-11-10MSI, ZIP, MSIX2028-11-14
PowerShell 7.7 (STS, .NET 11)GA announced 2026-11-10ZIP, MSIX (no MSI)Not yet listed on the lifecycle page

The end-of-support dates for 7.4, 7.5 and 7.6 come from the PowerShell Support Lifecycle page. That page was last updated on 2026-09-09 and still lists 7.7 as a preview without an end-of-support date. The GA of 7.7 as a Standard Term Support release on .NET 11 is documented in Announcing PowerShell 7.7 GA Release and on the v7.7.0 GitHub release, whose Windows assets are ZIP archives and one .msixbundle. The v7.6.10 release still carries x64, x86 and Arm64 MSI packages.

Install PowerShell 7 on Windows (updated 2026-09-22) states: "Beginning with the PowerShell 7.7.0 release, there is no MSI package available. WinGet only installs the MSIX package." The same page still describes the MSI as the "Best choice for Windows Servers and enterprise deployment scenarios" and documents its limits for MSIX: Store-based installations "are installed for a single user. There is no option to install it for all users." They do not support PowerShell remoting, cannot modify $PSHOME, and do not support Register-PSSessionConfiguration, Update-Help -Scope AllUsers, Enable-ExperimentalFeature -Scope AllUsers or Set-ExecutionPolicy -Scope LocalMachine.

In a reply under the 7.7 announcement, the PowerShell team answered a question about system-wide installation: "Installing for all users and service accounts isn't supported by the MSIX package yet. … Until then, the 7.6 MSI is the option for that scenario."

Three consequences follow for package baselines:

  • Any package, documentation or requirement rule that names PowerShell 7.4 or 7.5 now points to a release without security updates. These should move to 7.6.
  • An estate that needs pwsh for SYSTEM-context automation has, per the PowerShell team's own reply, the 7.6 MSI as its documented route until the MSIX gaps close. 7.6 is supported until 2028-11-14.
  • The 7.6 MSI exposes USE_MU (opt-in to updating through Microsoft Update, WSUS or Configuration Manager), ENABLE_MU and ADD_PATH, among other properties. ADD_PATH matters for the PSADT behaviour described below.

Where Windows PowerShell 5.1 Sits in Today's Deployment Stack

None of the product documentation reviewed for this article describes a setting that switches an agent-run script from Windows PowerShell 5.1 to PowerShell 7. Where the documentation names a host, it names Windows PowerShell or a 32-/64-bit choice.

Intune

Add PowerShell scripts to Windows devices in Intune (ms.date 2026-11-10) documents three script settings for platform scripts: Run this script using the logged on credentials (No runs the script in the system context), Enforce script signature check, and Run script in 64-bit PowerShell host, which defaults to No, meaning a 32-bit host. The troubleshooting section runs a script through agentexecutor.exe with $PSFolder = "C:\Windows\SysWOW64\WindowsPowerShell\v1.0". The page documents no edition choice.

Remediations script packages carry the same pattern of settings, including Run script in 64-bit PowerShell, and state that scripts without signature enforcement run with the Bypass execution policy.

For Win32 apps, Add and assign Win32 apps (ms.date 2026-11-11) states: "Calling powershell.exe in either of these fields will result in a 32-bit Powershell instance being launched. To force 64-bit Powershell execution, use the following command: %SystemRoot%\Sysnative\WindowsPowerShell\v1.0\powershell.exe". Requirement and detection scripts have the option Run script as 32-bit process on 64-bit clients, defaulting to a 64-bit process. The PowerShell script installer type uploads a script of up to 50 KB that "runs it in the same context as the app installer"; the page lists runAs32Bit as one of its script properties. Its interaction with PSADT wrappers is described in PowerShell Script Installers for Intune Win32 Apps.

Configuration Manager

The clearest statement is on the Configuration Manager PowerShell cmdlets overview. It says that all supported current branch versions support Windows PowerShell 5.1 and that the cmdlet library supports PowerShell 7, with ten exceptions that require the .NET Framework (Import-CMPackage, Import-CMDriverPackage, Import-CMTaskSequence, Export-CMPackage, Export-CMDriverPackage, Export-CMTaskSequence and the four *-CMReportingServicePoint cmdlets). Under known issues it adds:

"Current support is only for the Configuration Manager cmdlets. Other features of Configuration Manager that rely on PowerShell may not support version 7. For example, Run Scripts, CMPivot, or the Run PowerShell Script task sequence step."

The feature pages describe their host in Windows PowerShell terms:

  • Run Scripts: the client must run PowerShell 3.0 or later; "Currently, only PowerShell scripts are supported."
  • Application script detection: script types PowerShell, VBScript or JScript; the client calls PowerShell with -NoProfile; optional Run script as 32-bit process on 64-bit clients. The deployment type also offers Run installation and uninstall program as 32-bit process on 64-bit clients.
  • Compliance settings: discovery and remediation scripts in Windows PowerShell, VBScript or JScript, called with -NoProfile.
  • Client settings, Computer Agent: PowerShell execution policy configures "how Configuration Manager clients can run Windows PowerShell scripts"; default All Signed.
  • Run PowerShell Script task sequence step: "Use this step to run the specified Windows PowerShell script."
  • CMPivot: target clients need at least PowerShell 4, some entities PowerShell 5.0.

None of these pages offers a PowerShell 7 option.

PSADT 4.1.8 and 4.2 RC2

The PSADT requirements page for 4.1.x states: "PSAppDeployToolkit v4 fully supports Windows PowerShell 5.1 and PowerShell (Core) 7.4+" and requires .NET Framework 4.7.2 or higher. The page does not name 7.6 or 7.7 individually. The module manifest declares PowerShellVersion = '5.1.14393.0' in both 4.1.8 and 4.2.0-rc2. In RC2, ImportsFirst.ps1 loads assemblies from lib\net8.0 when $PSVersionTable.PSEdition is not Desktop, and from lib\net472 otherwise. The release status of 4.2 is covered in PSADT 4.2 RC2 for ConfigMgr and Intune Packagers.

The host decision for a typical package is made by Invoke-AppDeployToolkit.exe. In the source of both tags (src/PSADT.Invoke/PSADT.Invoke/Invoke.cs in 4.1.8, src/PSADT.Invoke/Program.cs in RC2), the launcher behaves as follows:

  • Default: Path.Combine(Environment.SystemDirectory, @"WindowsPowerShell\v1.0\PowerShell.exe"), started with -ExecutionPolicy Bypass -NonInteractive -NoProfile -NoLogo.
  • /32: the SysWOW64 copy of Windows PowerShell on 64-bit systems.
  • /Core: the first pwsh.exe found in the directories of the PATH environment variable; if none is found, the launcher throws "The [/Core] parameter was specified, but PowerShell Core was not found on this system." RC2's help text describes the switch as "Forces the deployment to use PowerShell 7, throwing if PowerShell 7 is not installed."
  • /32 together with /Core is rejected.
  • Without either switch, if a parent process is named pwsh, the launcher uses that parent's executable.

Read together with the Learn statement that MSIX installations are single-user and with issue #27562, the source implies that /Core in a SYSTEM-context deployment depends on a pwsh.exe that is reachable through the machine PATH, which the MSI provides through its ADD_PATH property. This is a reading of the source and the documentation, not a lab result. A wrapper started by a deployment agent with the default command line Invoke-AppDeployToolkit.exe -DeploymentType Install, with no pwsh parent process, runs in Windows PowerShell 5.1, and will continue to do so on every Windows version that keeps 5.1.

SurfaceHost per documentation or sourcePowerShell 7 option documented
Intune platform scripts32-bit (default) or 64-bit PowerShell hostNo
Intune RemediationsSetting Run script in 64-bit PowerShellNo
Intune Win32 install command with powershell.exe32-bit Windows PowerShell unless Sysnative path is usedNo
Intune Win32 detection and requirement scripts64-bit (default) or 32-bit processNo
ConfigMgr Run Scripts, CMPivot, Run PowerShell Script stepWindows PowerShell; PowerShell 7 "may not" be supportedNo
ConfigMgr detection methods, CI scriptsPowerShell called with -NoProfile; execution policy defined for Windows PowerShellNo
ConfigMgr cmdlet library (console side)Windows PowerShell 5.1 or PowerShell 7, ten cmdlets exceptedYes
PSADT Invoke-AppDeployToolkit.exeSystem32\WindowsPowerShell\v1.0\PowerShell.exe by defaultYes, /Core (requires pwsh.exe in PATH)

What Does Not Run Under pwsh Today

Two lists are relevant, and they have different causes.

The first is independent of packaging. Differences between Windows PowerShell 5.1 and PowerShell 7.x lists what PowerShell 7 removed. For deployment scripts the entries that appear most often are:

  • the WMI v1 cmdlets Get-WmiObject, Invoke-WmiMethod, Set-WmiInstance, Remove-WmiObject and Register-WmiEvent; the CIM cmdlets are the documented replacement
  • the *-EventLog cmdlets, including Write-EventLog and New-EventLog; Get-WinEvent and New-WinEvent remain
  • PowerShell snap-ins (Add-PSSnapin, Get-PSSnapin, Remove-PSSnapin) and custom snap-ins in general
  • Add-Computer, Remove-Computer, Test-ComputerSecureChannel, Reset-ComputerMachinePassword and Checkpoint-Computer
  • New-WebServiceProxy, the *-Transaction cmdlets and PowerShell Workflow
  • the modules Microsoft.PowerShell.LocalAccounts, PSScheduledJob, PSWorkflow and the ISE, which are no longer shipped with PowerShell

PowerShell 7 includes a Windows PowerShell Compatibility feature that loads some Windows PowerShell modules that still require the .NET Framework, as described in Migrating from Windows PowerShell 5.1 to PowerShell 7. Whether a specific module works through it has to be tested per module.

The second list exists only for the MSIX package and is the table in the previous section: SYSTEM context, remoting, DISM cmdlets, and everything that writes to $PSHOME, including the all-users profile and Set-ExecutionPolicy -Scope LocalMachine. A script that is fully PowerShell 7-compatible can still fail on the MSIX package for these reasons.

Warning
The product-side gaps in ConfigMgr are not covered by either list. The ConfigMgr cmdlet overview states that features such as Run Scripts, CMPivot and the Run PowerShell Script step "may not support version 7". A script that passes under pwsh on a workstation has not thereby been shown to work through these features.

Inventory Before Migration

KB5137172 asks for an inventory, not for a migration. In a ConfigMgr or Intune estate the inventory has two parts: the management objects that carry scripts, and the scripts and launchers on devices.

Management objects to export and review:

  • ConfigMgr: application deployment types (install and uninstall command lines, script detection methods), configuration items and global conditions with script settings, Run Scripts entries, task sequences with Run PowerShell Script or Run Command Line steps, and packages and programs that call powershell.exe.
  • Intune: platform scripts, Remediations script packages, Win32 app install and uninstall commands, PowerShell script installers, and requirement and detection scripts, each with its 32-/64-bit setting.
  • PSADT: the launch command of every wrapper (Invoke-AppDeployToolkit.exe with or without /32 or /Core, or powershell.exe -File Invoke-AppDeployToolkit.ps1), and the PSADT version per package.

On devices, the KB names scheduled tasks and tools that start powershell.exe. The following example script is read-only. It lists scheduled task actions whose command line starts powershell or pwsh, together with the run-as account, and scans folders such as a package source share for .ps1, .psm1, .cmd and .bat files that start a PowerShell host, declare #Requires -PSEdition or #Requires -Version, or call a subset of the cmdlets that the Learn differences page lists as removed in PowerShell 7.

powershell · 133 lines
#Requires -Version 5.1
<#
.SYNOPSIS
    Read-only inventory of PowerShell host dependencies: scheduled task actions
    and script files that start powershell.exe or pwsh.exe, declare #Requires
    edition or version statements, or call cmdlets that PowerShell 7 removed.
.NOTES
    Example script. Runs in Windows PowerShell 5.1 and PowerShell 7.
    Reads only; changes nothing. Run elevated to see all scheduled tasks.
#>
[CmdletBinding()]
param(
    # Folders to scan for script files, for example a package source share.
    [string[]] $ScriptRoot = @(),

    # Skip the scheduled task scan.
    [switch] $SkipScheduledTasks
)

# Subset of the cmdlets listed as removed in "Differences between
# Windows PowerShell 5.1 and PowerShell 7.x" (Microsoft Learn).
$removedInPS7 = @(
    'Get-WmiObject', 'Invoke-WmiMethod', 'Set-WmiInstance', 'Remove-WmiObject',
    'Register-WmiEvent', 'Get-EventLog', 'Write-EventLog', 'New-EventLog',
    'Clear-EventLog', 'Remove-EventLog', 'Limit-EventLog', 'Show-EventLog',
    'Add-PSSnapin', 'Get-PSSnapin', 'Remove-PSSnapin', 'New-WebServiceProxy',
    'Add-Computer', 'Remove-Computer', 'Checkpoint-Computer',
    'Test-ComputerSecureChannel', 'Reset-ComputerMachinePassword'
)

$hostPattern = '(?i)\b(powershell|pwsh)(\.exe)?\b'

if (-not $SkipScheduledTasks) {
    foreach ($task in Get-ScheduledTask -ErrorAction SilentlyContinue) {
        foreach ($action in $task.Actions) {
            # COM handler actions have no Execute property.
            $execute = $action.CimInstanceProperties['Execute']
            if ($null -eq $execute -or [string]::IsNullOrEmpty($execute.Value)) { continue }
            # Arguments are included so that cmd.exe /c powershell.exe ... is found too.
            $commandLine = ($execute.Value + ' ' + $action.Arguments).Trim()
            if ($commandLine -match $hostPattern) {
                [pscustomobject]@{
                    Source = 'ScheduledTask'
                    Item   = $task.TaskPath + $task.TaskName
                    RunAs  = $task.Principal.UserId
                    Shell  = $Matches[1].ToLowerInvariant()
                    Detail = $commandLine
                }
            }
        }
    }
}

foreach ($root in $ScriptRoot) {
    if (-not (Test-Path -LiteralPath $root -PathType Container)) {
        Write-Warning "Folder not found: $root"
        continue
    }

    $files = Get-ChildItem -LiteralPath $root -Recurse -File -ErrorAction SilentlyContinue |
        Where-Object { $_.Extension -in '.ps1', '.psm1', '.cmd', '.bat' }

    foreach ($file in $files) {
        # Wrapper batch files and scripts that start a PowerShell host.
        $hostLines = Select-String -LiteralPath $file.FullName -Pattern '(?i)\b(powershell|pwsh)\.exe\b'
        foreach ($line in $hostLines) {
            [pscustomobject]@{
                Source = 'File'
                Item   = $file.FullName
                RunAs  = $null
                Shell  = $line.Matches[0].Groups[1].Value.ToLowerInvariant()
                Detail = 'Line {0}: {1}' -f $line.LineNumber, $line.Line.Trim()
            }
        }

        if ($file.Extension -notin '.ps1', '.psm1') { continue }

        $tokens = $null
        $parseErrors = $null
        $ast = [System.Management.Automation.Language.Parser]::ParseFile(
            $file.FullName, [ref] $tokens, [ref] $parseErrors)

        if ($parseErrors.Count -gt 0) {
            [pscustomobject]@{
                Source = 'File'
                Item   = $file.FullName
                RunAs  = $null
                Shell  = $null
                Detail = 'Parse errors: {0}' -f $parseErrors.Count
            }
        }

        $requirements = $ast.ScriptRequirements
        if ($null -ne $requirements) {
            if ($requirements.RequiredPSEditions.Count -gt 0) {
                [pscustomobject]@{
                    Source = 'File'
                    Item   = $file.FullName
                    RunAs  = $null
                    Shell  = $null
                    Detail = '#Requires -PSEdition ' + ($requirements.RequiredPSEditions -join ', ')
                }
            }
            if ($null -ne $requirements.RequiredPSVersion) {
                [pscustomobject]@{
                    Source = 'File'
                    Item   = $file.FullName
                    RunAs  = $null
                    Shell  = $null
                    Detail = '#Requires -Version ' + $requirements.RequiredPSVersion
                }
            }
        }

        $commands = $ast.FindAll({
            param($node)
            $node -is [System.Management.Automation.Language.CommandAst]
        }, $true)

        foreach ($command in $commands) {
            $name = $command.GetCommandName()
            if ($name -and $removedInPS7 -contains $name) {
                [pscustomobject]@{
                    Source = 'File'
                    Item   = $file.FullName
                    RunAs  = $null
                    Shell  = $null
                    Detail = 'Line {0}: {1} (removed in PowerShell 7)' -f $command.Extent.StartLineNumber, $name
                }
            }
        }
    }
}

A typical call against a package share, with output to CSV, is .\Get-PSHostDependency.ps1 -ScriptRoot '\\fs01.corp.example.com\Packages' | Export-Csv -Path .\ps-host-inventory.csv. In Windows PowerShell 5.1, -NoTypeInformation suppresses the type header line; in PowerShell 7.7 the parameter writes a deprecation warning and has no effect, according to the 7.7 announcement. The script finds literal references only. Commands built at run time, aliases, and cmdlets used inside modules that a script imports are not detected, and a match on Get-WmiObject means only that the script needs a change before it can run in PowerShell 7, not that it fails today.

Note
Checks performed on the script: the PowerShell language parser ([System.Management.Automation.Language.Parser]::ParseFile) reports zero errors in Windows PowerShell 5.1 (5.1.26100) and PowerShell 7.7.0, both started with -NoProfile. The script was run in both editions against a folder of test files and against mocked scheduled task objects created with New-ScheduledTaskAction, and produced the same results. It was not run against a production estate. PSScriptAnalyzer was not used.

For a deeper analysis, PSScriptAnalyzer offers the rule PSUseCompatibleCommands, which is disabled by default and compares commands against platform profiles. The profiles bundled by default end at PowerShell 7.0; current targets need a profile generated with the PSCompatibilityCollector module, as the rule page describes. The improved compatibility checks announced in the PowerShell team post were not yet published as of 2026-11-26.

A Staged Plan for 2026–2027

The documentation supports a plan in which nothing that works is changed now, and every later step waits for a documented trigger.

StageTriggerAction
1. NowKB5137172 publishedNo change to existing packages, scripts, detection methods or CIs. Record the PowerShell host of every management object and of every PSADT wrapper's launch command. Run the device inventory on a reference set of devices.
2. Now7.4/7.5 end of support, 2026-11-10Replace PowerShell 7.4 and 7.5 packages and requirement rules with 7.6 LTS (MSI). Do not standardise SYSTEM-context automation on 7.7 while it ships as MSIX only.
3. Next new workNew wrappers and scriptsWrite and test new scripts under both powershell.exe and pwsh.exe. Avoid the cmdlets the Learn differences page lists as removed. Keep the default PSADT launcher command unless /Core is needed and pwsh.exe is on the machine PATH.
4. Preview of the next Windows client or Windows Server 2028Insider or preview buildsTest the existing package catalogue on a preview build: 5.1 as FOD on a new installation, PSADT wrappers, Intune detection scripts, ConfigMgr Run Scripts and task sequence steps.
5. When #27562 is reported resolved in a released buildIssue status and release notesRe-test pwsh as SYSTEM through the Intune Management Extension, the ConfigMgr client and PSADT /Core. Until then, do not plan on the MSIX-delivered pwsh for agent-run scripts.
6. When Microsoft publishes a removal dateUpdate to KB5137172Plan the migration of the remaining 5.1-only scripts against that date and the FOD details.

Packaging teams with a large PSADT catalogue. The catalogue needs no change for current Windows versions. The useful work now is the inventory of launch commands and the replacement of 7.4 baselines. Wrappers that already use /Core should be checked for the assumption that PowerShell 7 comes from an MSI that adds itself to PATH.

ConfigMgr-centred estates. Run Scripts, CMPivot, compliance settings, detection methods and task sequence steps are documented in Windows PowerShell terms, and the cmdlet overview states that PowerShell 7 support is limited to the cmdlet library. These features stay on Windows PowerShell 5.1 until Microsoft documents otherwise. The console-side automation that uses the ConfigurationManager module can already be tested under PowerShell 7, except for the ten listed cmdlets.

Intune-centred estates. Platform scripts, Remediations, Win32 commands and detection scripts document only a 32-/64-bit host choice. The Sysnative path for 64-bit Windows PowerShell remains the documented way to control bitness in Win32 command lines. Scripts that need PowerShell 7 can launch pwsh.exe from an installed 7.6 MSI, which is a packaging practice and not an Intune feature.

Rule of thumb: Windows PowerShell 5.1 stays the documented host for agent-run deployment scripts on every Windows version released so far; inventory now, test new work on both editions, and wait for a released fix of the SYSTEM gap before any deployment depends on the PowerShell 7 that ships with Windows.


Sources: KB5137172 — Windows PowerShell 5.1 Deprecation, KB5134574 — Windows PowerShell shortcut names are being updated to include version 5.1, KB5065506 — PowerShell 2.0 removal from Windows, PowerShell Team Blog — PowerShell 7 is coming to Windows (post and author replies), PowerShell Team Blog — Announcing PowerShell 7.7 GA Release (post and author replies), GitHub — PowerShell #27565 Tracking: MSIX packaging gaps for PowerShell 7 (description and status update of 2026-11-11), GitHub — PowerShell #27562, GitHub — PowerShell v7.7.0 release, GitHub — PowerShell v7.6.10 release, Microsoft Learn — PowerShell Support Lifecycle, Microsoft Learn — Install PowerShell 7 on Windows, Microsoft Learn — Differences between Windows PowerShell 5.1 and PowerShell 7.x, Microsoft Learn — Migrating from Windows PowerShell 5.1 to PowerShell 7, Microsoft Learn — PSUseCompatibleCommands, Microsoft Learn — Features removed or no longer developed in Windows Server (Windows Server 2028 Preview tab), Microsoft Learn — What's new in Windows Server 2028 Preview, Microsoft Learn — Add PowerShell scripts to Windows devices in Intune, Microsoft Learn — Remediations, Microsoft Learn — Add and assign Win32 apps, Microsoft Learn — Configuration Manager PowerShell cmdlets overview, Microsoft Learn — Create and run PowerShell scripts (ConfigMgr), Microsoft Learn — Create applications (ConfigMgr), Microsoft Learn — Create custom configuration items (ConfigMgr), Microsoft Learn — About client settings (ConfigMgr), Microsoft Learn — Task sequence steps (ConfigMgr), Microsoft Learn — CMPivot (ConfigMgr), PSAppDeployToolkit docs — Requirements (4.1.x), PSAppDeployToolkit source at tags 4.1.8 (Invoke.cs, PSAppDeployToolkit.psd1) and 4.2.0-rc2 (Program.cs, ImportsFirst.ps1, PSAppDeployToolkit.psd1). All KB numbers, dates, version numbers, support dates, paths, settings and quoted statements verified against the sources linked above. GitHub issue content is reported as the issue states it and is not treated as a Microsoft product commitment. PSADT launcher behaviour is described from source; no lab test of PowerShell 7 as SYSTEM is claimed. The inventory script was parse-checked and run against test files in Windows PowerShell 5.1 and PowerShell 7.7.0. As of 2026-11-26.