Skip to content

Add compatibility profiles for Windows 11 with PowerShell 5.1, 7.4, 7.5 and 7.6 - #2228

Open
Ethan Aldrich (0x000NULL) wants to merge 2 commits into
PowerShell:mainfrom
0x000NULL:feat/2152-current-profiles
Open

Ethan Aldrich (0x000NULL) wants to merge 2 commits into
PowerShell:mainfrom
0x000NULL:feat/2152-current-profiles

Conversation

@0x000NULL

@0x000NULL Ethan Aldrich (0x000NULL) commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Summary

This adds UseCompatibleCommands / UseCompatibleTypes profiles for current platforms. Until now, the newest bundled profiles were for PowerShell 7.0 on Windows 10 1903.

PowerShell ID
5.1 win-4_x64_10.0.26200.0_5.1.26100.9711_x64_4.0.30319.42000_framework
7.4 win-4_x64_10.0.26200.0_7.4.21_x64_8.0.32_core
7.5 win-4_x64_10.0.26200.0_7.5.12_x64_9.0.21_core
7.6 win-4_x64_10.0.26200.0_7.6.7_x64_10.0.13_core

The first commit fixes two PSCompatibilityCollector bugs that came up while generating these. It also adds PSCompatibilityCollector/Tests/Collection.Tests.ps1, whose two tests fail without the fixes.

  • .NET 5+ reports .NET <version>, not .NET Core <version>, so the 7.x profiles came out named and tagged framework.
  • On PowerShell 7, Microsoft.PowerShell.Diagnostics didn't load because its type data was already in the session. The collector removed that type data, then retried in a new runspace, which loads the same type data again. It now retries in the same runspace first.
    • Without this fix, Get-WinEvent, New-WinEvent and Get-Counter were missing from the 7.x profiles.

If the size of this PR is a concern, I can split the collector fixes into their own PR.

The docs tables list the new profiles, and UseCompatibleCommands.Tests.ps1 has cases for each one. The old profiles are unchanged.

Fixes #2152

How the profiles were generated

  • I generated them on a Windows 11 Enterprise (10.0.26200) x64 machine with the script below, collect-profile.ps1.
  • PowerShell builds used:
    • 5.1: the inbox Windows PowerShell
    • 7.6.7: the MSI install
    • 7.4.21 and 7.5.12: the official win-x64 zips, SHA256 checked
  • You'd prefer profiles from a CI image. I can regenerate them on a windows-2025 GitHub Actions runner if you want.
  • The machine wasn't a clean image, so the script excludes what a stock install doesn't have. This is to avoid another case like PSAvoidOverwritingBuiltInCmdlets (core-6.1.0-*) returns warning for Write-Log, which is not a built-in cmdlet #2146.
    • Modules: per-user modules, non-inbox modules under Program Files, and RSAT / Hyper-V / Containers modules. These are excluded with -ExcludeModulePathPrefix.
    • Native commands: 85 System32 executables are removed. They come from drivers, OEM or third-party software, RSAT, Hyper-V and Graphics Tools.
    • No user names, host names or user paths are in the output.
  • Things in the data that look odd but are expected:
    • The 5.1 profile's OperatingSystem.Name reads "Windows 10 Enterprise". Windows PowerShell 5.1 takes it from the registry ProductName, which still says Windows 10 on Windows 11.
    • pwsh.exe and createdump.exe are among the native commands only in the 7.6 profile. 7.4 and 7.5 ran from portable zips that aren't on PATH.
  • Known collector gaps, which a CI image would hit too:
    • Microsoft.PowerShell.Operation.Validation is missing. Its module checks $ExecutionContext.Host.Runspace and throws inside the collector.
    • Windows PowerShell-only modules such as Defender, which PowerShell 7 only reaches through WinCompat, aren't in the 7.x profiles.

Thanks to ajn142 for offering in the issue to generate profiles and for raising the concern about third-party modules leaking in.

How tested

All runs use a build from this branch on .NET SDK 8.0.426, with PowerShell 7.6.7.

  • Tests/Rules/*Compatib*: 312 passed, 0 failed.
  • PSCompatibilityCollector/Tests, after importing the built module from PSCompatibilityCollector/out: 69 passed, 0 failed. These are the existing 67 plus the 2 new tests.
  • Earlier run of Tests/Build, Engine, Rules and Documentation on this branch: 0 failed.

The profile JSON is single-line, like the existing profiles. Sizes: 29.2, 37.6, 38.2 and 38.9 MB.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Change is not breaking (profiles are added, none removed)
  • Make sure all .cs, .ps1 and .psm1 files have the correct copyright header
  • Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
  • This PR is ready to merge and is not Work in Progress.
collect-profile.ps1
param(
    [Parameter(Mandatory)] [string] $CollectorPsd1,
    [Parameter(Mandatory)] [string] $OutDir
)

$ErrorActionPreference = 'Stop'

# Stock Windows PATH only, so per-user and third-party executables stay out of NativeCommands
$env:PATH = @(
    "$env:SystemRoot\system32"
    "$env:SystemRoot"
    "$env:SystemRoot\System32\Wbem"
    "$env:SystemRoot\System32\WindowsPowerShell\v1.0\"
    "$env:SystemRoot\System32\OpenSSH\"
    # A portable (zip) PowerShell is not on a stock PATH, and its location would leak into the profile
    if ($PSHOME.StartsWith($env:ProgramFiles, 'OrdinalIgnoreCase')) { $PSHOME }
) -join ';'

$sys32Modules = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\Modules"
$pfWinPSModules = "$env:ProgramFiles\WindowsPowerShell\Modules"
$stockPfModules = 'PackageManagement', 'PowerShellGet', 'Pester', 'PSReadLine', 'Microsoft.PowerShell.Operation.Validation'

# Modules from RSAT, Hyper-V/Containers and other optional features that a stock Windows 11 install does not have
$nonStockSys32Modules = @(
    'ActiveDirectory', 'BestPractices', 'GroupPolicy', 'RemoteDesktop', 'ServerManager', 'ServerManagerTasks',
    'IscsiTarget', 'NFS', 'Microsoft.ReFsDedup.Commands', 'HgsClient', 'HgsDiagnostics',
    'Hyper-V', 'VMDirectStorage', 'HostComputeService', 'HostNetworkingService'
)

$exclude = @(
    Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'PowerShell'
    Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'WindowsPowerShell'
    "$env:ProgramFiles\PowerShell\Modules"
    Split-Path -Parent (Split-Path -Parent $CollectorPsd1)
)
$exclude += $nonStockSys32Modules | ForEach-Object { Join-Path $sys32Modules $_ }
$exclude += Get-ChildItem $pfWinPSModules -Directory | Where-Object Name -notin $stockPfModules | ForEach-Object FullName

Import-Module $CollectorPsd1

$name = Get-PSCompatibilityPlatformName
$outFile = Join-Path $OutDir "$name.json"
Write-Host "Profile name: $name"
Write-Host "Excluded module path prefixes:"
$exclude | ForEach-Object { Write-Host "  $_" }

New-PSCompatibilityProfile -OutFile $outFile -ExcludeModulePathPrefix $exclude -Validate -WarningAction Continue

# Native commands come from System32, which also holds executables from drivers, OEM tools, RSAT,
# Hyper-V/Containers and other optional features. Drop those so only stock Windows 11 commands remain.
$nonStockNativeCommands = @(
    # Not signed as part of Windows: drivers, OEM utilities and third-party software
    'DbxSvc.exe', 'EEURestart.exe', 'GigabyteDownloadAssistant.exe', 'GigabyteUpdateService.exe', 'KOBDrvAPIW64.EXE',
    'MCU.exe', 'NpcapHelper.exe', 'NvContainerRecovery.bat', 'RtkAudUService64.exe', 'WlanHelper.exe', 'amdlogum.exe',
    'app-refresh-reset.bat', 'app-upgrade-reset.bat', 'appverif.exe', 'atieah64.exe', 'atieclxx.exe', 'clinfo.exe',
    'dgtrayicon.exe', 'dns-sd.exe', 'microsoft.windows.softwarelogo.showdesktop.exe', 'nvdebugdump.exe',
    'nvidia-pcc.exe', 'nvidia-smi.exe', 'pwNative.exe', 'py.exe', 'pyw.exe', 'vsjitdebugger.exe',
    'vulkaninfo-1-999-0-0-0.exe', 'vulkaninfo.exe', 'wpbbin.exe', 'xgamecontrol.exe', 'xgamehelper.exe'
    # RSAT: AD DS, Group Policy and Server Manager tools
    'adsiedit.msc', 'csvde.exe', 'dcdiag.exe', 'domain.msc', 'dsa.msc', 'dsac.exe', 'dsacls.exe', 'dsadd.exe',
    'dsdbutil.exe', 'dsget.exe', 'dsmgmt.exe', 'dsmod.exe', 'dsmove.exe', 'dsquery.exe', 'dsrm.exe', 'dssite.msc',
    'gpfixup.exe', 'gpmc.msc', 'gpme.msc', 'gptedit.msc', 'ISM.exe', 'ldifde.exe', 'ldp.exe', 'mtedit.exe',
    'ntdsutil.exe', 'redircmp.exe', 'redirusr.exe', 'rendom.exe', 'repadmin.exe', 'netdom.exe', 'ServerManager.exe',
    'LbfoAdmin.exe'
    # Hyper-V and Containers
    'CCG.exe', 'hcsdiag.exe', 'hnsdiag.exe', 'hvc.exe', 'nmbind.exe', 'nmscrub.exe', 'nvspinfo.exe', 'vfpctrl.exe',
    'virtmgmt.msc', 'vmcompute.exe', 'vmconnect.exe', 'vmms.exe', 'vmplatformca.exe', 'vmsp.exe', 'vmwp.exe'
    # Graphics Tools optional feature, and ReFS dedup (matches the excluded module)
    'DXCap.exe', 'DXCpl.exe', 'd3dconfig.exe', 'VsGraphicsDesktopEngine.exe', 'VsGraphicsRemoteEngine.exe',
    'ReFsDedupSvc.exe'
)
# Round-trip through the collector's own serializer so the file format is unchanged
$serializer = [Microsoft.PowerShell.CrossCompatibility.Retrieval.JsonProfileSerializer]::Create()
$profileData = $serializer.DeserializeFromFile([string]$outFile)
$removed = foreach ($c in $nonStockNativeCommands) { if ($profileData.Runtime.NativeCommands.Remove($c)) { $c } }
Write-Host "Removed $(@($removed).Count) non-stock native commands"

$serializer.SerializeToFile($profileData, [string]$outFile)
Get-Item $outFile

Two problems stopped PSCompatibilityCollector from producing correct
profiles on current PowerShell:

- .NET 5 and later report RuntimeInformation.FrameworkDescription as
  ".NET <version>", not ".NET Core <version>", so profiles were named
  and tagged as "framework". Treat anything that is not ".NET Framework"
  as Core.
- Importing a module whose type data is already loaded (for example
  Microsoft.PowerShell.Diagnostics on PowerShell 7) failed. The collector
  removed the conflicting type data but then retried in a new runspace,
  which loads the same default type data again. Retry in the same
  runspace first, so Get-WinEvent, New-WinEvent and Get-Counter are no
  longer missing from PowerShell 7 profiles.
….5 and 7.6

Generated with PSCompatibilityCollector on Windows 11 Enterprise
(10.0.26200), using Windows PowerShell 5.1.26100.9711 and the official
x64 builds of PowerShell 7.4.21, 7.5.12 and 7.6.7.

Modules and executables that a stock Windows 11 install does not have
were left out: RSAT, Hyper-V and Containers modules and tools, per-user
modules, other modules installed under Program Files, and driver, OEM
and third-party executables in System32.

List the new profiles in the UseCompatibleCommands and
UseCompatibleTypes docs and add test cases for them.

Fix PowerShell#2152

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The large, manually filtered profiles generated on a non-clean machine need human validation against a clean Windows baseline.

No open issues 🎉

What changed in this PR

Adds Windows 11 compatibility profiles for PowerShell 5.1, 7.4, 7.5, and 7.6, addressing #2152.

Changes:

  • Corrects modern .NET runtime detection and retries module imports after removing conflicting type data.
  • Adds collector regression tests and command compatibility cases.
  • Documents the four new profiles.
File Description
Tests/​Rules/​UseCompatibleCommands.Tests.ps1 Adds Windows 11 command and parameter compatibility cases.
PSCompatibilityCollector/​Tests/​Collection.Tests.ps1 Tests runtime detection and Diagnostics module collection.
PSCompatibilityCollector/​Microsoft.PowerShell.CrossCompatibility/​Collection/​PowerShellDataCollector.cs Retries imports in the same runspace after resolving type-data conflicts.
PSCompatibilityCollector/​Microsoft.PowerShell.CrossCompatibility/​Collection/​PlatformInformationCollector.cs Recognizes modern .NET as Core.
docs/​Rules/​UseCompatibleTypes.md Lists new type compatibility profiles.
docs/​Rules/​UseCompatibleCommands.md Lists new command compatibility profiles.

Review effort: Balanced

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Ethan Aldrich (@0x000NULL) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

@ajn142

ajn142 commented Oct 19, 2026

Copy link
Copy Markdown

Whoa, this is awesome! My job role changed shortly after submitting #2152 and life has gotten busy, I haven't had a chance to follow up on this myself. Really appreciate you taking a go at it Ethan Aldrich (@0x000NULL)!

@0x000NULL

Copy link
Copy Markdown
Author

Whoa, this is awesome! My job role changed shortly after submitting #2152 and life has gotten busy, I haven't had a chance to follow up on this myself. Really appreciate you taking a go at it Ethan Aldrich (Ethan Aldrich (@0x000NULL))!

Not a problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lack of compatibility profiles for current PowerShell Core versions, Windows 11, Windows PowerShell on Windows 11.

3 participants