I have a simple powershell script that simply runs the following:
Write-Output "myCommand myCommand -param $env:MyParameter"
myCommand -param $env:MyParameter
The first one writes out the command that is being executed below. The $env:MyParameter is expanded correctly with its value. However, the actual command that is executed on the next line, does not. The command myCommand gets the actual string that I pass, "$env:MyParameter."