Test-IsWindows.ps1
function Test-IsWindows { <# .SYNOPSIS Returns $true when run on Windows, else $false .DESCRIPTION Variables like $isWindows were introduced in PowerShell 7 but are missing in Windows PowerShell. This function provides a uniform way of finding out whether the script runs on Windows or another operating system. .EXAMPLE Test-IsWindows returns $true when executed on Windows, else $false #> if ($PSVersionTable['PSVersion'].Major -le 5) { $true } else { $isWindows } } |