Private/Test-PSCore.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
function Test-PSCore { <# .SYNOPSIS Returns True is running on PowerShell Core. .NOTES Author: Aaron Parker Twitter: @stealthpuppy .PARAMETER Version The version of PowerShell Core. Optionally specified where value needs to be something other than 6.0.0. #> [CmdletBinding()] [OutputType([System.Boolean])] param ( [Parameter(Position = 0)] [System.String] $Version = "6.0.0" ) # Check whether current PowerShell environment matches or is higher than $Version if (($PSVersionTable.PSVersion -ge [System.Version]::Parse($Version)) -and ($PSVersionTable.PSEdition -eq "Core")) { Write-Output -InputObject $true } else { Write-Output -InputObject $false } } |