* 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