我已經創建了從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
就是這樣!雖然錯誤沒有指向它,但將會話作爲參數傳遞會使其工作。我如何將你標記爲答案? –