Can't pass a script block as a parameter to powershell.exe via -Command
I'm trying this $Global:commandBlock={ Start-Transcript -path $projectFolder\gruntLog.txt; grunt $argList; Stop-Transcript } $cmdProc=start-process powershell -ArgumentList ('-command `$Global:commandBlock') -WorkingDirectory $fwd -PassThru -NoNewWindow:$NoNewWindow And keep getting $commandBlock : The term '$Global:commandBlock' is not recognized as the name of a cmdlet, function, script file, or operable program. My guess was it has to do with scope. But making variable global didn't help. Adding -args $commandBlock like that: -ArgumentList ('-command `$Global:commandBlock -args "