Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows PowerShell脚本块语法给我带来了麻烦_Windows_Powershell_Console - Fatal编程技术网

Windows PowerShell脚本块语法给我带来了麻烦

Windows PowerShell脚本块语法给我带来了麻烦,windows,powershell,console,Windows,Powershell,Console,我正试图在控制台中使用powershell执行脚本块,但我不能完全按照我想要的方式使用语法。我需要另一双眼睛,因为我已经盯着这个看了很长时间了。有人能指出我做错了什么吗 C:\Users\Administrator.MAUL>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -Inputformat None -ExecutionPolicy Unrestricted -Command

我正试图在控制台中使用powershell执行脚本块,但我不能完全按照我想要的方式使用语法。我需要另一双眼睛,因为我已经盯着这个看了很长时间了。有人能指出我做错了什么吗

C:\Users\Administrator.MAUL>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -Inputformat None -ExecutionPolicy Unrestricted -Command "&  {'C:\Users\Administrator.MAUL\Scripts\InstallTransportAgent.ps1' -ExchangeDir 'C:\Program Files\Microsoft\Exchange Server\V14' -AgentDir 'C:\Users\Administrator.MAUL\Project\TransportAgent\bin\x64\Debug' }"
结果是:

You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:126
+ &  {'C:\Users\Administrator.MAUL\InstallTransportAgent.ps1' - <<<< ExchangeDir 'C:\Program Files\Microsoft\Exchange Server\V14' -AgentDir 'C:\Users\Administrator.MAUL\Project\TransportAgent\bin\x64\Debug' }
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
   ception
    + FullyQualifiedErrorId : ExpectedValueExpression
必须在“-”运算符的右侧提供值表达式。
第1行字符:126
+&{C:\Users\Administrator.MAUL\InstallTransportAgent.ps1'-尝试将此作为命令(我无法测试此命令):


(实际上不需要脚本块)

我想我可能已经找到了答案:在脚本块中,我还需要包含第二个呼叫操作符,如下所示:

... -Command "& {&'path/to/exe' ...}"

据我所知,需要脚本块,因为此命令是在Windows Server 2008控制台中执行的,而不是在powershell中执行的。据我所知,不需要脚本块:),对于.ps1脚本(如示例中所示)或可执行文件都不需要脚本块。执行-command参数的是powershell。
... -Command "& {&'path/to/exe' ...}"