If I run the following version test on Windows 10 or Windows 11, they both report $Major as 10 and $Minor as 0, so this test is not sufficient to determine if we are running on Windows 10 or Windows 11.
[version]$OSVersion = [Environment]::OSVersion.Version $Major = $OSVersion.Major $Minor = $OSVersion.Minor # Other ways to test: # $OSVersion = [Version](Get-ItemProperty -Path "$($Env:Windir)\System32\hal.dll" -ErrorAction SilentlyContinue).VersionInfo.FileVersion.Split()[0] # [version]$OSVersion = Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty Version In PowerShell, how can we distinguish if we are running in Windows 10 or Windows 11 ?