Private/Test-WinOnly.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function Test-WinOnly {
    [CmdletBinding()]
    param(
        [switch]$ThrowOnFail
    )

    if ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop') {
        return $true
    } else {
        if ($ThrowOnFail) {
            $errorMessage = "Only supported on Windows platforms."
            throw [Management.Automation.ValidationMetadataException]$errorMessage
        }
        return $false
    }

}