在批处理文件中执行powershell脚本[重复]

问题描述

|                                                                                                                   这个问题已经在这里有了答案:                                                      

解决方法

        通常,您可以执行以下操作:
 @powershell -command \"yourpowershellcommand\"
您可以直接使用
powershell.exe
,但我建议您使用上述形式的ѭ2form     ,        命令行帮助“ 3”涵盖了以下内容: -命令     执行指定的命令(和任何参数),就像它们     在Windows PowerShell命令提示符下键入,然后退出,除非     指定了NoExit。 Command的值可以是字符串“ \-”。或     脚本块。     如果Command的值为\“-\”,则从标准中读取命令文本     输入。     如果Command的值是一个脚本块,则必须将脚本块括起来     大括号({})。您只能在运行PowerShell.exe时指定脚本块 最后显示一个示例: 例子     PowerShell -PSConsoleFile SqlSnapIn.Psc1     PowerShell-版本1.0 -NoLogo -InputFormat文本-OutputFormat XML     PowerShell -Command {Get-EventLog -LogName安全性}     PowerShell -Command \“&{Get-EventLog -LogName安全} \”