我正在编写一个任务来定期远程重启一些服务器应用程序池。我正在使用 Invoke-Command 如下:
Invoke-Command -ComputerName $server {Restart-WebItem "IIS:\AppPools\DefaultAppPool"}
这很好用;但是,如果我将应用程序池参数化如下
$appPool = "IIS:\AppPools\DefaultAppPool"
Invoke-Command -ComputerName $server {Restart-WebItem $appPool}
它失败了
Unexpected object type.
Parameter name: pspath
我认为这只是一个语法问题,但我不知道是什么。