Invoke-Command:找不到接受实参的位置参数 [英] Invoke-Command : A positional parameter cannot be found that accepts argument
本文介绍了Invoke-Command:找不到接受实参的位置参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在PowerShell中的以下脚本中遇到了上述问题。 我似乎找不到问题所在。该脚本需要2个参数,我已在命令行中提供了它们,但仍抛出错误?
命令:
PS C:> powershell.exe -ExecutionPolicy Bypass invoke-command installboot.ps1 -computername 192.168.162.1 -argumentlist MyServerMyNewService, option2
脚本:
param(
[Parameter(Mandatory=$true)]
[string] $IISName,
[Parameter(Mandatory=$true)]
[string] $installmode
)
write-host "IISName: " $IISName
write-host "Install Mode: " $installmode
推荐答案
尝试使用-Command
参数,例如:
powershell.exe -ExecutionPolicy Bypass -Command {invoke-command -file installboot.ps1 -computername 192.168.162.1 -argumentlist MyServerMyNewService,option2}
这篇关于Invoke-Command:找不到接受实参的位置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文