我已经创建了从Windows 10计算机(客户端)到Windows Server 2012 R2计算机(服务器)的PowerShell会话并尝试卸载功能:远程调用 - 要删除的命令 - WindowsFeature不能用作模块不可用
$session | Invoke-Command -ScriptBlock { Remove-WindowsFeature Server-Gui-Shell }
我收到的错误:
Invoke-Command : The term 'Remove-WindowsFeature' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
如果我RDP服务器机器,并启动PowerShell中,命令是可用的,但在客户机上它不是,也没有模块ServerManager
。
这意味着我试图在服务器上运行的命令需要以某种方式在客户端上可用,这对我来说似乎很奇怪。
我错过了什么吗?
'Invoke-Command'不通过管道接受'PSSession'。 – PetSerAl
就是这样!虽然错误没有指向它,但将会话作为参数传递会使其工作。我如何将你标记为答案? –