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