How to open Powershell Console Window from Powershell

前端 未结 5 876
眼角桃花
眼角桃花 2020-12-23 14:35

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

相关标签:
5条回答
  • 2020-12-23 14:56

    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.

    0 讨论(0)
  • 2020-12-23 14:58

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

    start powershell {.\scriptInNewPSWindow.ps1}
    
    0 讨论(0)
  • 2020-12-23 15:05

    This will do it:

    Invoke-Item C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    
    0 讨论(0)
  • 2020-12-23 15:06

    This will open a new window.

    Either:

    start-process powershell
    

    Or:

    start powershell
    
    0 讨论(0)
  • 2020-12-23 15:15

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

    0 讨论(0)
提交回复
热议问题