How to open Powershell Console Window from Powershell

人走茶凉 提交于 2019-11-29 21:12:36

This will do it:

Invoke-Item C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Andy Arismendi

This will open a new window.

Either:

start-process powershell

Or:

start powershell

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

start powershell {.\scriptInNewPSWindow.ps1}

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.

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.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!