0
我想在控制檯中使用powershell執行腳本塊,並且我無法完全像我想要的那樣獲得語法工作。我需要另一雙眼睛,因爲我一直在盯着這個很長一段時間。有人能指出我做錯了什麼嗎?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
盡我所知,腳本塊是必需的,因爲此命令在Windows Server 2008控制檯中執行,而不是在PowerShell中執行。 –
不需要腳本塊,就像我可以告訴的那樣:),既不是.ps1腳本(如示例中),也不是可執行文件。它是執行-Command參數的PowerShell。 –
是的,很對。我過度格式化。 –