Cómo abrir la ventana de la consola de Powershell desde Powershell


Estoy escribiendo un script para usar varias sesiones plink (PuTTY) como una versión de Windows de clusterssh. Sin embargo, estoy atascado porque quiero abrir varias ventanas de Powershell desde Powershell. Cuando escribo el comando para powershell, se abre una nueva sesión. Esto es similar a escribir bash en bash. Quiero múltiples ventanas físicas abiertas.

He intentado-windowstyle, así como los otros args en vano. Me preguntaba si hay alguna forma que conozcas. Realmente aprecio tu ayuda. Me miré y no encontré nada ya aquí. Gracias por su tiempo.

Author: msmith81886, 2013-03-27

4 answers

Esto lo hará:

Invoke-Item C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
 15
Author: EBGreen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-27 19:16:08

Esto abrirá una nueva ventana.

O bien:

start-process powershell

O:

start powershell
 103
Author: Andy Arismendi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-17 09:19:54

Si está intentando abrir una nueva ventana y lanzar un nuevo script:

start powershell {.\scriptInNewPSWindow.ps1}
 10
Author: jeffski13,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-23 02:58:42

Esto funciona para mí:

$argList = "-file `"$Location\script.ps1`"" Start-Process powershell -argumentlist $argList

(Los backsticks son necesarios. Esto se puede copiar directamente.) Las variables se pueden usar en el parámetro "- file " (como un conjunto al principio del script para reflejar la ubicación del archivo) y los espacios pueden aparecer en la variable debido a los backsticks.

Se editó para usar una solución de dos líneas (la variable "arg argList") porque PowerShell puede alterar las cosas de otra manera.

 1
Author: seagull,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-20 10:57:54