arashzgh arashzgh - 10 months ago 98
PowerShell Question

how i can start process with large multiline script block in powershell?

i wanna start process powershell with script block .
like this code.

start-process powershell.exe -ArgumentList "-noexit","-command {
set-Set-ExecutionPolicy bypass -force
get-help get-process
get-command -commandtype cmdlet


The argument for Command should be another element in the ArgumentList not merged into -command.


Start-Process powershell.exe -ArgumentList "-noexit", "-command", "Get-Process"

This applies whether the thing you're executing is a simple command or a longer command (a very long string).