internal/functions/Test-Windows.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function Test-Windows {
    <#
        .SYNOPSIS
            Internal tool, used to detect non-Windows platforms
 
        .DESCRIPTION
            Some things don't work with Windows, this is an easy way to detect
 
        .EXAMPLE
            if (-not (Test-Windows)) { return }
 
            The calling function will stop if this function returns true.
    #>

    [CmdletBinding()]
    param (
        [switch]$Not
    )
    [bool]$result = -not (($PSVersionTable.Keys -contains "Platform") -and $psversiontable.Platform -ne "Win32NT")
    if ($Not) { $result = -not $result}
    return $result
}