GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add compatibility profiles for Windows 11 with PowerShell 5.1, 7.4, 7.5 and 7.6 by 0x000NULL · Pull Request #2228 · PowerShell/PSScriptAnalyzer Conversation
|
| 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 <version>, not .NET Core <version>, so the 7.x profiles came out named and tagged framework.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.
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
collect-profile.ps1.windows-2025 GitHub Actions runner if you want.-ExcludeModulePathPrefix.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.Microsoft.PowerShell.Operation.Validation is missing. Its module checks $ExecutionContext.Host.Runspace and throws inside the collector.Thanks to ajn142 for offering in the issue to generate profiles and for raising the concern about third-party modules leaking in.
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.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.
.cs, .ps1 and .psm1 files have the correct copyright headercollect-profile.ps1param( [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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The large, manually filtered profiles generated on a non-clean machine need human validation against a clean Windows baseline.
No open issues 🎉
Adds Windows 11 compatibility profiles for PowerShell 5.1, 7.4, 7.5, and 7.6, addressing #2152.
Changes:
| 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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)! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Not a problem! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| --- | ||
| description: Use compatible commands | ||
| ms.date: 07/21/2026 | ||
| ms.date: 10/18/2026 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
those dates come from msdocs. because we need to sync with their repo 2 way, please undo this change. this date only gets changes on msdocs side and then later gets synced to us
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| --- | ||
| description: Use compatible types | ||
| ms.date: 07/21/2026 | ||
| ms.date: 10/18/2026 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
those dates come from msdocs. because we need to sync with their repo 2 way, please undo this change. this date only gets changes on msdocs side and then later gets synced to us
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The large profiles generated from a customized machine need human validation against a clean Windows 11 baseline.
No open issues 🎉
Review effort: Balanced
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, meant to update them for some time :-) Only thing to discuss internally whether we delete some old ones as those JSON files add a lot to the footprint of PSSA installation
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The date is owned by the msdocs repo and synced back here; only the profile table rows belong in this change.
|
Done — reverted |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
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.
There was an error while loading. Please reload this page.