How to open Powershell Console Window from Powershell

前端 未结 5 875
眼角桃花
眼角桃花 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.

提交回复
热议问题