Add proper error when trying to run on older PS versions (#62634)
This commit is contained in:
parent
7711524718
commit
d4ec9422a3
2 changed files with 8 additions and 0 deletions
2
changelogs/fragments/pwsh-minimum.yaml
Normal file
2
changelogs/fragments/pwsh-minimum.yaml
Normal 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
|
|
@ -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" }
|
||||
|
|
Loading…
Reference in a new issue