arashzgh arashzgh - 2 months ago 22x
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).