2017-05-07 16 views
0

PowerShellスクリプトcmdコマンドで実行する必要があります。このコマンドは、リモートコマンドラインで実行されます。だから私は私のスクリプトPowerShellのリモートホストへのcmdコマンドの実行

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?サーバーはドメインにありますが、romote hostdはありません。

答えて

関連する問題