private/Tests/Test-IsWindows11.ps1

function Test-IsWindows11 {
    <#
    .SYNOPSIS
        Returns $true when the current operating system is Windows 11
        (any build / release).
 
    .NOTES
        Author: David Segura
        Company: Recast Software
    #>

    [OutputType([bool])]
    param ()

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