0

I have tried to install a .exe file with PowerShell on remote computer but I have following error:

Connecting to remote server failed with the following error message : 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.

I run the following command:

Invoke-Command -ComputerName y.y.y.y -ScriptBlock{"d:UltraVNC_1_2_10_X86_Setup"

I changed the execution policy to RemoteSigned, but that didn't help.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
C. Bogdan
  • 15
  • 1
  • 2
  • 10
  • Possible duplicate of [Powershell remoting with ip-address as target](http://stackoverflow.com/questions/6587426/powershell-remoting-with-ip-address-as-target) – Ansgar Wiechers May 03 '16 at 08:22

2 Answers2

0

If the computer is password protected, try using a PSCredential object :

$user = "SRV\test"
$ip = "75.12.35.36"
$pass = "P455W0RD" | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $pass)

And use the command as following :

Invoke-Command -ComputerName $ip -Credential $cred {your instructions}

If that does not work verify that the WinRM service is currently running on the remote machine :

get-service winrm
start-service winrm

And also add the remote machine to your TrustedHosts list :

Set-Item WSMan:\localhost\Client\TrustedHosts -Value $ip -force
Svart
  • 1
  • 2
  • I have try your suggestions ,but same error appear. – C. Bogdan May 04 '16 at 06:30
  • Does the remote account allow remote accesses ? What happens when you put some Powershell code between {} instead ? Invoke-Command -ComputerName $ip -Credential $cred {Get-Process} – Svart May 04 '16 at 08:01
  • Yes, remote account allow remote accesses. When I run "invoke -command " the powershell console return me same error . I can run another remote command like "restart-computer" for example ,the issue appear when I try run invoke-command . – C. Bogdan May 04 '16 at 10:08
0

I solved that problem adding the target nodes to the trusted host list

Set-Item WSMan:\localhost\client\trustedhosts <target node ip> -force -concatenate

Let say that I want to connect from PC1 to PC2(192.168.1.2) and PC3(192.168.1.3) using winrm, so I added PC2 and PC3 to the trusted host list of PC1

Set-Item WSMan:\localhost\client\trustedhosts 192.168.1.2 -force -concatenate

Set-Item WSMan:\localhost\client\trustedhosts 192.168.1.3 -force -concatenate
JCF
  • 368
  • 3
  • 15