0
我需要在PowerShell腳本cmd命令中運行,該命令將在遠程cmd行上運行。所以,我把我的劇本運行cmd命令到PowerShell上的遠程主機
Invoke-Command -ComputerName $line -scriptblock {cmd.exe /c "whoami"} -credential $Cred
和它的作品,但只有在遠程主機上已運行Enable-PSRemoting -Force
否則我得到的錯誤:
[192.168.1.1] Connecting to remote server 192.168.1.1 failed with the following error message : Access denied. For more information, see the about_Remote_Trou
bleshooting Help topic.
+ CategoryInfo : OpenError: (192.168.1.1:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken
我需要運行這個命令了許多(約200)遠程主機,所以問題是我怎樣才能做到這一點,而不需要手動在每個遠程主機上運行Enable-PSRemoting -Force
?服務器在域中但不支持hostd。
服務器所屬的域名,但遠程主機沒有。 – TraPS