您的位置:首页 > 运维架构 > Shell

如何通过其他工具的命令行启动PowerShell

2012-08-02 15:10 411 查看

很多时候,我们需要在其他工具中启动PowerShell来执行PowerShell命令,比如Cmd.exe或批处理文件。下面就来介绍下启动PowerShell的基本语法。

调用Windows PowerShell控制台基本语法:

PowerShell[.exe]
[-PSConsoleFile <file> | -Version <version>]
[-EncodedCommand <Base64EncodedCommand>]
[-ExecutionPolicy <ExecutionPolicy>]
[-File <filePath> <args>]
[-InputFormat {Text | XML}]
[-NoExit]
[-NoLogo]
[-NonInteractive]
[-NoProfile]
[-OutputFormat {Text | XML}]
[-Sta]
[-WindowStyle <style>]
[-Command { - | <script-block> [-args <arg-array>]
| <string> [<CommandParameters>] } ]

关于每个参数的含义,可以通过命令powershell -help来查看。

举例:

在一个命令提示符下或一个批处理文件中,可以用下列命令得到当前运行进程的列表:

Powershell -nologo -noprofile -command get-process

如果想使命令行执行powershell命令后保持运行不退出,可以增加-NoExit参数

Powershell -noexit -command get-process

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: