Add proper error when trying to run on older PS versions (#62634)

This commit is contained in:
Jordan Borean 2019-09-24 08:43:14 -04:00 committed by GitHub
parent 7711524718
commit d4ec9422a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- Windows - Add a check for the minimum PowerShell version so we can create a friendly error message on older hosts

View file

@ -1,4 +1,10 @@
&chcp.com 65001 > $null
if ($PSVersionTable.PSVersion -lt [Version]"3.0") {
'{"failed":true,"msg":"Ansible requires PowerShell v3.0 or newer"}'
exit 1
}
$exec_wrapper_str = $input | Out-String
$split_parts = $exec_wrapper_str.Split(@("`0`0`0`0"), 2, [StringSplitOptions]::RemoveEmptyEntries)
If (-not $split_parts.Length -eq 2) { throw "invalid payload" }