* Wrap funcs to flatten and upload env vars with new func prepareEnvVars.
While the wrapped funcs could be combined, keeping them separate
simplifies testing.
* Configure/refactor std and elevated PS to use new funcs to prepare,
upload and dot source env vars.
* Dot sourcing the env vars in this way avoids the need to embed them
directly in the command string. This avoids the need to escape the env
vars to ensure the command string is correctly parsed.
* Characters within the env vars that are special to PS (such as $'s
and backticks) will still need to be escaped to allow them to be
correctly interpreted by PS.
* The std and elevated PS commands now inject env vars into the remote
env via the same mechanism. This ensures consistent behaviour across the
two command types.
Fixes#5471
Revert so that we can merge a different branch that's had more recent work instead
This reverts commit ba518637d4, reversing
changes made to e56849c605.
* Wrap funcs to flatten and upload env vars with new func prepareEnvVars.
While the wrapped funcs could be combined, keeping them separate
simplifies testing.
* Configure/refactor std and elevated PS to use new funcs to prepare,
upload and dot source env vars.
* Dot sourcing the env vars in this way avoids the need to embed them
directly in the command string. This avoids the need to escape the env
vars to ensure the command string is correctly parsed.
* Characters within the env vars that are special to PS (such as $'s
and backticks) will still need to be escaped to allow them to be
correctly interpreted by PS.
* The std and elevated PS commands now inject env vars into the remote
env via the same mechanism. This ensures consistent behaviour across the
two command types.
Fixes#5471
* Setting $ProgressPreference to SilentlyContinue makes no difference
when -EncodedCommand is used - any output to the progress stream
still appears on stderr.
* Delete file containing encode/decode functions since we no longer
need them.
* Fixes leak of output on progress streams for both normal and elevated
commands.
* Since we no longer base64 encode, ensure any characters special to XML
are correctly escaped in the elevated command. This ensures correct
parsing once the command is wrapped within the elevatedTemplates XML
based Task Scheduler definition.
Fixes#4322
Fix a bug in the size of string that was returned when decoding a base64 string
Added tests around encoding and decoding powershell scripts. Used [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes('powershell commands')) | clip to generate what base 64 strings should look like
Fix unit tests for not showing progress stream when using powershell
Ensure that progress stream does not get leaked into stdout
Using Write-Output instead of Write-Host since PS v5 now leaks the host stream to stderr