2011-09-02 81 views
13

有點困惑w /遠程執行powershell命令。我有一臺名爲ServerA的測試服務器(Win 2k8-R2-SP1),它正確啓用了PowerShell遠程功能。從我的開發機器(Win 2k8-R2-SP1),我能夠正確遠程執行powershell命令。 但是,當我嘗試從不同的服務器稱爲服務器B(贏2K8-R2)執行相同的命令,我收到以下錯誤混淆Powershell行爲

[ServerA] Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (:) [], PSRemotingTransportException + FullyQualifiedErrorId : PSSessionStateBroken

這三款機器都在同一個域中。我的困惑是,從我的開發機器,我完全能夠連接到ServerA並執行命令。

請問ServerB沒有SP1的事實,有所作爲?請指教。我使用的是具有所有3臺服務器上的管理權限的相同域帳戶。

而我正在嘗試的命令是 Invoke-Command -ComputerName ServerA -ScriptBlock {Get-UICulture}

請幫忙。

感謝

回答

25

運行winrm quickconfig或從服務器B Enable-PSRemoting -force

驗證服務與get-service winrm

http://technet.microsoft.com/en-us/magazine/ff700227.aspx

同時運行,從當地的dev的盒子運行此:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force 
+0

Hiya ..謝謝。我嘗試了這一點,並沒有看到任何行爲改變。 –

+0

@Prasanna K Rao - 查看我更新的答案。 – manojlds

+0

謝謝..即使這沒有幫助。我嘗試從我的開發箱訪問URL http:// serverA:5985 /,並且出現Http 404錯誤。但是,從ServerB,我得到一個'內容阻塞'錯誤。我不確定這個信息是否有幫助。謝謝 –

4

我有同樣的問題還有,一臺機器上過去一直在爲遠程PowerShell工作。在我的情況下,解決方案是清除安全日誌。它已經滿了,我相信這是爲了防止powershell建立適當的安全連接。

1

下固定我的問題:

要麼你得空可以使用下面的CMD命令來檢查你的iplisten列表:

netsh http show iplist 

或者如果地址添加循環回到它那裏任何其它地址:

netsh http add iplisten 127.0.0.1 
1

,省去你管理的每一個服務器上啓用WinRM的,你可以運行這個批處理腳本:

要求:

用法:EnablePSRemoting.bat PC。txt

@echo off 
for /f %%f in (%1) do (
    psexec.exe \\%%f -accepteula -h -d -s powershell.exe "enable-psremoting -force" 
    echo Enabled on %%f 
) 
0

我一直在尋找答案的天,我發現這個問題;

似乎沒有安裝IIS 7 .NET可擴展性組件導致此問題。我們有2012 R2 Exchange 2010服務器;

https://technet.microsoft.com/en-us/library/dd421841(v=exchg.80).aspx

我通過的powershell進入該安裝它;

看到這裏的先決條件爲Exchange 2010

https://technet.microsoft.com/en-us/library/bb691354(v=exchg.141)

我們的這個Exchange服務器只郵箱角色,其他的仍然是CAS和集線器傳輸;

所以我們需要這個命令;

Add-WindowsFeature NET-Framework-Features,RSAT-Clustering,Web-Mgmt-Console,WAS-Process-Model,Web-Basic-Auth,Web-Lgcy-Mgmt-Console,Web-Metabase,Web-Net -Ext,Web-Server,Web-Windows-Auth -Restart

Web-Net-Ext的一部分安裝了IIS 7.NET Extensibility組件。 無需重啓。

只是我的2美分,也許這可以幫助別人:-)