Start PowerShell script from one window in another

To call a PowerShell (PS) script from another PowerShell script and have it run in a second terminal window without exiting, you can use a script similar to:
Start-Process PowerShell.exe -ArgumentList "-noexit", "-command .\local_path\start_server.ps1"

When developing in Visual Studio Code, I often find myself with a few different services I want to start up. To make those easier, I turn them into a PS script and just kick that off through the many different terminals you can have integrated directly into VSCode. But as those grow, it'd be easier to have one all inclusive script. It took me a while to find all of the necessary pieces to put this together, so I'm documenting the various pieces needed to make this all work.

Start-Process is one of many ways to kick off a script, and the linked article has good explanations for why you might choose one over another. Just Start is an alias for start-process, and type hints suggested I use the fully qualified name which I went with.

PowerShell.exe is the actual process I'm calling, and then I specify the -ArgumentList that I want to pass to PowerShell. This -ArgumentList is required from what I've been able to find, as just passing -NoExit after PowerShell.exe comes up with an error about not being a recognized argument. The second argument, -command and the file path is the actual command to be run inside the new PowerShell terminal window that was opened. SS64, an easy to read command line reference site has a description of the various arguments you can pass into PowerShell if you would like to learn more.

Author image
Hi, I'm Aaron Grossman, a Business Intelligence developer documenting what I've learned as I continue to grow my career. I can be reached at me@aaronjgrossman.com.