arashzgh arashzgh - 3 years ago 411
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

Answer Source

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).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download