win async - use full path for powershell (#70703)
This commit is contained in:
parent
9dda393d70
commit
154efd97f2
2 changed files with 4 additions and 1 deletions
2
changelogs/fragments/win_async_full_path.yml
Normal file
2
changelogs/fragments/win_async_full_path.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- windows async - use full path when calling PowerShell to reduce reliance on environment vars being correct - https://github.com/ansible/ansible/issues/70655
|
|
@ -87,7 +87,8 @@ $bootstrap_wrapper = {
|
||||||
$bootstrap_wrapper = $bootstrap_wrapper.ToString().Replace('$pipe_name = ""', "`$pipe_name = `"$pipe_name`"")
|
$bootstrap_wrapper = $bootstrap_wrapper.ToString().Replace('$pipe_name = ""', "`$pipe_name = `"$pipe_name`"")
|
||||||
$bootstrap_wrapper = $bootstrap_wrapper.Replace('$bytes_length = 0', "`$bytes_length = $($payload_bytes.Count)")
|
$bootstrap_wrapper = $bootstrap_wrapper.Replace('$bytes_length = 0', "`$bytes_length = $($payload_bytes.Count)")
|
||||||
$encoded_command = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($bootstrap_wrapper))
|
$encoded_command = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($bootstrap_wrapper))
|
||||||
$exec_args = "powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded_command"
|
$pwsh_path = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||||
|
$exec_args = "`"$pwsh_path`" -NonInteractive -NoProfile -ExecutionPolicy Bypass -EncodedCommand $encoded_command"
|
||||||
|
|
||||||
# create a named pipe that is set to allow only the current user read access
|
# create a named pipe that is set to allow only the current user read access
|
||||||
$current_user = ([Security.Principal.WindowsIdentity]::GetCurrent()).User
|
$current_user = ([Security.Principal.WindowsIdentity]::GetCurrent()).User
|
||||||
|
|
Loading…
Reference in a new issue