我对远程执行 powershell 命令有点困惑。我有一个名为 ServerA 的测试服务器 (Win 2k8-R2-SP1),它正确启用了 powershell 远程处理。在我的开发机器 (Win 2k8-R2-SP1) 上,我能够正确远程执行 powershell 命令。
但是,当我尝试从名为 ServerB (Win 2k8-R2) 的不同服务器执行相同的命令时,出现以下错误
[ServerA] 连接到远程服务器失败,并显示以下错误消息:客户端无法连接到请求中指定的目的地。验证目标上的服务正在运行并且正在接受请求。请查阅在目标(最常见的是 IIS 或 WinRM)上运行的 WS-Management 服务的日志和文档。
如果目标是 WinRM 服务,请在目标上运行以下命令来分析和配置 WinRM 服务:“winrm Quickconfig”。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
+ 类别信息:OpenError:(:) [],PSRemotingTransportException
+ FullQualifiedErrorId : PSSessionStateBroken
所有三台机器都在同一个域中。我的困惑是,从我的开发机器上,我完全能够连接到 ServerA 并执行命令。
ServerB 没有 SP1 会产生影响吗?请指教。我使用的域帐户在所有 3 台服务器上都具有管理员权限。
我正在尝试的命令是
Invoke-Command -ComputerName ServerA -ScriptBlock {Get-UICulture}
。
请帮忙。
谢谢
Am a bit confused w/ remote executing a powershell command. I have a test server (Win 2k8-R2-SP1) called ServerA, which has powershell remoting enabled correctly. From my dev machine (Win 2k8-R2-SP1), am able to remote execure powershell commands correctly.
But, when I try to execute the same command from a different server called ServerB (Win 2k8-R2), I get the following error
[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
All three machines are in the same domain. My confusion is that from my dev machine, I am perfectly able to connect to ServerA and execute the command.
Will the fact that ServerB does not have SP1, make a difference? Please advise. I am using the same domain account which has admin rights on all 3 servers.
And the command that I am trying is
Invoke-Command -ComputerName ServerA -ScriptBlock {Get-UICulture}
.
Please help.
Thanks
发布评论
评论(7)
从 ServerB 运行
winrm Quickconfig
或Enable-PSRemoting -force
。使用
get-service winrm
http://technet.microsoft 验证服务是否正在运行。 com/en-us/magazine/ff700227.aspx
另外,从本地开发箱运行此命令:
Run
winrm quickconfig
orEnable-PSRemoting -force
from ServerB.Verify service is running with
get-service winrm
http://technet.microsoft.com/en-us/magazine/ff700227.aspx
Also, run this from your local dev box:
我也遇到过同样的问题,在一台过去用于远程 powershell 的机器上。就我而言,解决方案是清除安全日志。它已满,我相信这会阻止 powershell 建立适当的安全连接。
I've had this same problem as well, on a machine that was working for remote powershell in the past. In my case the solution was to clear the Security Log. It was full, and I believe this was preventing powershell from making a proper secure connection.
以下解决了我的问题:
您必须清空 iplisten 列表,可以使用以下 CMD 命令进行检查:
或者如果有任何其他地址,则将环回地址添加到其中:
The following fixed my problem:
You either have to empty your iplisten list which can be checked using the following CMD command:
or to add the loop back address to it if there is any other addresses:
我遇到了同样的问题并通过以下方式解决了。运行
返回以下错误。
就我而言,这是我机器上运行的虚拟机管理程序服务的虚拟网卡。当我将其更改为 Private 后,winrm Quickconfig 运行时没有错误。我仍然在连接到某些机器时遇到问题,并遇到与此线程中描述的相同的故障。为了解决这个问题,我检查并启动了 winrm 服务(它已停止)。
I was having this same issue and resolved in the following way. Running
returned the below error.
In my case, this was a virtual NIC for a hypervisor service I was running on my machine. Once I changed this to Private, winrm quickconfig ran without error. I still had issues connecting to some machines and getting the same failure as described in this thread. To resolve, I checked for and started the winrm service where it was stopped.
为了避免在您管理的每台服务器上启用 WinRM,您可以运行此批处理脚本:
要求:
用法:EnablePSRemoting.bat PC 。TXT
To save having to enable WinRM on every single server you manage, you can run this batch script:
Requirements:
Usage: EnablePSRemoting.bat PCs.txt
我已经寻找答案好几天了,我发现了问题所在;
似乎未安装 IIS 7 .NET Extensibility 组件导致此问题。我们有一台 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和HUB传输;
所以我们需要这个命令;
添加 WindowsFeature NET 框架功能、RSAT 集群、Web 管理控制台、WAS 进程模型、Web 基本身份验证、Web-Lgcy-管理控制台、Web 元数据库、Web-Net-Ext、Web -Server,Web-Windows-Auth -Restart
Web-Net-Ext 部分安装了 IIS 7.NET 扩展性组件。
无需重新启动。
只是我的 2 美分,也许这对其他人有帮助:-)
I have been looking for the answer for days and I found the issue;
It seems that the IIS 7 .NET Extensibility component was not installed causing this issue. We have a 2012 R2 Exchange 2010 server;
https://technet.microsoft.com/en-us/library/dd421841(v=exchg.80).aspx
I installed it by entering this in powershell;
See here the prerequisites for Exchange 2010.
https://technet.microsoft.com/en-us/library/bb691354(v=exchg.141)
This Exchange server of ours has only the mailbox role, the other is still CAS and HUB transport;
So we need this command;
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
The part of Web-Net-Ext installed the IIS 7.NET Extensibility component.
No need to restart.
Just my 2 cents, maybe this helps someone else :-)
就我而言,WinRM 未配置正确。这是我用来远程启用它的方法:
In my case, WinRM was not configured correctly. This is what I used to enable it remotely: