private/Test-IsWindows11.ps1

function Test-IsWindows11 {
    <#
    .SYNOPSIS
        Tests whether the operating system caption identifies Windows 11
 
    .DESCRIPTION
        Queries Win32_OperatingSystem through CIM and checks whether its Caption
        contains Windows 11. Returns $false when CIM data is unavailable or the
        caption does not match.
 
    .EXAMPLE
        PS> Test-IsWindows11
 
        Tests whether the current operating system caption contains Windows 11.
 
    .INPUTS
        None. This function does not accept pipeline input.
 
    .OUTPUTS
        System.Boolean. Returns $true when the operating system caption contains
        Windows 11; otherwise, returns $false.
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 1.0.0
        Date: 2026-08-28
    #>

    [OutputType([bool])]
    param ()

    $os = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction SilentlyContinue
    return ($null -ne $os -and $os.Caption -like '*Windows 11*')
}