Opening new PowerShell Windows from PowerShell and Running Commands in them
This is mostly a post to my future self, but I hope it helps someone else too.
I am working on a blog post where I want to -
- launch multiple commands one after the other
- each command opens its own PowerShell window
- the window stays open after the command has finished
- the window can be closed easily (by pressing a button rather than typing exit or closing it with the mouse)
Here is the first way -
start pwsh { -Command "dir; pause" } ; start pwsh { -Command "dir; pause" }; start pwsh { -Command "dir; pause" }
And another -
for ($i=0; $i -lt 3; $i++)
{
start pwsh { -Command "dir; pause" }
}