private/Test-IsWindows1125H2OrLater.ps1
|
function Test-IsWindows1125H2OrLater { <# .SYNOPSIS Tests whether the operating system is Windows 11 25H2 or later .DESCRIPTION Queries Win32_OperatingSystem through CIM and checks that Caption contains Windows 11 and BuildNumber is at least 26200. Returns $false when CIM data is unavailable or either value does not match. .EXAMPLE PS> Test-IsWindows1125H2OrLater Tests whether the current operating system is Windows 11 build 26200 or later. .INPUTS None. This function does not accept pipeline input. .OUTPUTS System.Boolean. Returns $true for Windows 11 build 26200 or later; otherwise, returns $false. .NOTES Author: David Segura Company: Recast Software Version: 1.0.0 Date: 2026-10-05 #> [OutputType([bool])] param () $os = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction SilentlyContinue if ($null -eq $os -or $os.Caption -notlike '*Windows 11*') { return $false } [int]$buildNumber = 0 return ([int]::TryParse([string]$os.BuildNumber, [ref]$buildNumber) -and $buildNumber -ge 26200) } |