94

I am writing a script to use multiple plink (PuTTY) sessions as a Windows version of clusterssh. I am stuck however because I want to open multiple Powershell windows from powershell. When I type the command for powershell, it opens a new session. This is similar to typing bash in bash. I want multiple physical windows opening.

I tried -windowstyle as well as the other args to no avail. I was wondering if there is a way you know of. I really appreciate your help. I looked and didn't find anything already here. Thanks for your time.

msmith81886
  • 2,286
  • 2
  • 20
  • 27

5 Answers5

200

This will open a new window.

Either:

start-process powershell

Or:

start powershell
codeape
  • 97,830
  • 24
  • 159
  • 188
Andy Arismendi
  • 50,577
  • 16
  • 107
  • 124
34

if you are trying to open a new window and launch a new script:

start powershell {.\scriptInNewPSWindow.ps1}
jeffski13
  • 581
  • 5
  • 6
  • Works great when you need to kick off a series of processes (i.e. npm). There might be a better way, but as a developer that needs to get working quickly, this is great! – Kyle Barnes Mar 05 '20 at 18:57
26

This will do it:

Invoke-Item C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
EBGreen
  • 36,735
  • 12
  • 65
  • 85
4

This works for me:

$argList = "-file `"$Location\script.ps1`"" Start-Process powershell -argumentlist $argList

(The backticks are necessary. This can be copied outright.) Variables can be used in the "-file" parameter (such as one set at the beginning of the script to reflect the location of the file) and spaces can appear in the variable due to the backticks.

Edited to use a two-line solution (the "$argList" variable) because PowerShell can mangle things otherwise.

seagull
  • 187
  • 11
4

To start Powershell 6 from a PS console start pwsh might do the trick.
It starts in the same folder.

(I haven't delved into it but I guess PS6's pwsh.exe has to be in the path for it to work.)

LosManos
  • 7,195
  • 6
  • 56
  • 107