2013-10-22 45 views
1

我在PowerShell中遇到了以下問題。 我似乎無法找到問題。該腳本需要2個參數,並且我在命令行上提供了它們,但它仍然會引發錯誤?Invoke-Command:無法找到接受參數的位置參數

命令:

PS C:\> powershell.exe -ExecutionPolicy Bypass invoke-command installboot.ps1 -computername 192.168.162.1 -argumentlist MyServer\MyNewService, option2 

腳本:

param(
    [Parameter(Mandatory=$true)] 
    [string] $IISName, 
    [Parameter(Mandatory=$true)] 
    [string] $installmode 
) 

write-host "IISName: " $IISName 
write-host "Install Mode: " $installmode 

回答

3

-Command參數例如爲:

powershell.exe -ExecutionPolicy Bypass -Command {invoke-command -file installboot.ps1 -computername 192.168.162.1 -argumentlist MyServer\MyNewService,option2} 
試試吧
相關問題