0

I have written powershell script which connects to a remote server and executes a batch file

$password = ConvertTo-SecureString "pwd" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("user", $password )
Invoke-Command -ComputerName 10.10.10.10 -credential $cred -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'C:\batchfile.bat'"}

but i am getting an error:

 [‎10.10.10.10]Error while connecting to the server:  The WinRM client
 cannot process the request. Default authentication may be used with an
 IP address under the following conditions: the transport is HTTPS or
 the destination is in the TrustedHosts list, and   explicit
 credentials are provided. Use winrm.cmd to configure TrustedHosts.
 Note that computers in the TrustedHosts list might not be
 authenticated. For more information on how to set TrustedHosts run

 the   following command: winrm help config. For more information, see
     the about_Remote_Troubleshooting Help topic  At line:1 char:1
     + Invoke-Command -ComputerName 10.10.10.10 -credential $cred -ErrorAct ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     + CategoryInfo          : OpenError: (10.10.10.10:String) [], PSRemotingTransportException
        + FullyQualifiedErrorId : CannotUseIPAddress,PSSessionStateBroken

I got stuck. Please help me in this issue.

I have tried adding the name to the Trusted host also

Sravani Chinta
  • 71
  • 2
  • 11
  • The error is super clear and specific. If you use the IP to connect to the machine then you ***must*** meet the requirements specified. Are those requirements met in your environment? – EBGreen May 03 '18 at 13:39
  • This question is a dup. See the answer to https://stackoverflow.com/questions/6587426/powershell-remoting-with-ip-address-as-target – Adam May 03 '18 at 14:10

0 Answers0