2016-05-03 12 views
0

我曾嘗試遠程計算機上使用PowerShell安裝.exe文件,但我有以下錯誤:我無法連接到遠程服務器

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.

我運行下面的命令:

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

我將執行策略更改爲RemoteSigned,但這沒有幫助。

+0

[Powershell的遠程與IP地址作爲目標(的可能的複製http://stackoverflow.com/questions/ 6587426 /的powershell-遠程-與 - ip-address-as-target) –

回答

0

如果電腦有密碼保護,請嘗試使用PSCredential對象:

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

,並使用命令如下:

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

如果不起作用驗證WinRM服務是目前運行在遠程機器上:

get-service winrm 
start-service winrm 

並且還將遠程機器添加到yo烏爾TrustedHosts列表:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value $ip -force 
+0

我嘗試了你的建議,但同樣的錯誤出現。 –

+0

遠程帳戶是否允許遠程訪問?當你在{}之間放置一些Powershell代碼時會發生什麼? 調用命令-ComputerName $ ip -Credential $ cred {Get-Process} – Svart

+0

是的,遠程帳戶允許遠程訪問。當我運行「invoke -command」時,powershell控制檯返回同樣的錯誤。例如,我可以運行另一個遠程命令,例如「restart-computer」,當我嘗試運行invoke-command時,會出現該問題。 –

0

我解決了這個問題將目標節點可信主機列表

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

讓我們說,我想從PC1連接到PC2(192.168.1.2)和PC3( 192.168.1.3)使用WinRM的,所以加入PC2和PC3到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