PowerShell function to check the currently running platform. Exits if it's the wrong one.

<#
.SYNOPSIS
    Checks the currrently running platform. Exits if it's the wrong one.

.EXAMPLE
    Assert-Platform Win*
#>
function Assert-Platform([string[]] $platforms) {
    foreach ($platform in $platforms) {
        if ([environment]::OSVersion.Platform -match $platform) {
            return
        }
    }
    Skip-Platform
}

<#
.SYNOPSIS
    Writes the skipped platform name to output
    and exits the currently running script.

    Called by Assert-Platform.

.EXAMPLE
    Skip-Platform

    SkippedPlatform
    ---------------
            Unix
#>
function Skip-Platform() {
    $platform = [environment]::OSVersion.Platform
    New-Object PSObject -Property @{SkippedPlatform = $platform } | Write-Output
    exit
}