PowerShell 脚本打开一个新的 PowerShell 窗口并运行命令

问题描述

我正在寻找一种编写脚本的方法,该脚本能够打开新的 PowerShell 窗口并运行命令。例如。我想启动 PowerShell,在这个窗口中我需要运行一个脚本来打开一个新的 PowerShell 窗口,在该窗口中执行命令 pwd。

解决方法

试试这个命令

Start-Process powershell.exe -ArgumentList "-noexit"  



 Start-Process powershell -ArgumentList "-noexit","-noprofile","-command &{Get-Location}"

启动窗口最大化我们的参数-WindowStyle Maximized

提供更多代码以获取更多信息