Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

For loop to open multiple powershell windows

I'm looking for a way to open multiple powershell windows through a script. I tried with the following code, but it doesn't work.

for($1 = 1 ; $i -le 3; $i++)
{
    Start-Process powershell.exe
}

How can I reach this goal?

question from:https://stackoverflow.com/questions/65891908/for-loop-to-open-multiple-powershell-windows

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Not sure where $1 came from, change it to this:

for($i = 1 ; $i -le 3; $i++)
{
    Start-Process powershell.exe
}

and it'll work.

What's the end goal? Opening up new powershell processes will be slow and isn't usually necessary.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...