Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run powershell in new window

Tags:

powershell

I would like to run new powershell window with parameters. I was trying to run following:

powershell -Command "get-date"

but everything happens in same console. Is there a simple way to do this?

like image 780
Piotr Stapp Avatar asked Aug 09 '13 09:08

Piotr Stapp


1 Answers

To open a new PowerShell Window from PowerShell:

Start-Process PowerShell

Or my personal favorite:

Start-Process PowerShell -WindowStyle Maximized

Then you could typeGet-Datewithout having to deal with the -ArgumentList's tendency to close itself. I still haven't found a way to open a new PowerShell process with the -ArgumentList Parameter, without it immediately closing after it runs. For Instance:

Start-Process PowerShell -ArgumentList "Get-Date"

or simply

Start-Process PowerShell -ArgumentList Get-Date

Will Close Immediately after running the process.

In order to get it to wait before closing you could add:

Start-Process PowerShell -ArgumentList 'Get-Date; Read-Host "Press Enter"'

Since the -Wait Parameter seems to do nothing at all in this case.

FYI - PowerShell Suggested Syntax is actually:

Start-Process -FilePath "powershell.exe"

But since PowerShell is a standard Windows Application in the %SystemRoot%\system32 Environment Variables the command line(s) should recognize a simple

Powershell

Command

like image 67
T-Fred Avatar answered Oct 14 '22 23:10

T-Fred