简体   繁体   English

如何在 Powershell V3 中启用 powershell 远程处理?

[英]How to enable powershell remoting in Powershell V3?

I'm running powershell 3.0 in Windows 7 and I'm connected to a domain.我在 Windows 7 中运行 powershell 3.0 并且我已连接到域。

These are the logs I get when I run Enable-PSRemoting:这些是我运行 Enable-PSRemoting 时得到的日志:

WinRM has been updated to receive requests.
WinRM service type changed successfully.

Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2"
Machine="localhost"><f:Message><f:ProviderFault provider="Config provider" path="%systemroot%\system32\WsmSvc.dll"><f:WSManFault
xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2" Machine="mycomputername.mydomainname"><f:Message>Unable to check the sta
the firewall. </f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
At line:1 char:1
+ Set-WSManQuickConfig
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand

Oops...in my Inbound Rules of the Firewall settings, the Windows Remote Management(HTTP-In) Rule was not added.糟糕...在我的防火墙设置的入站规则中,没有添加 Windows 远程管理(HTTP-In)规则。 I added it and the issue got resolved.我添加了它,问题得到了解决。 So, make sure you have all the inbound rules configured for the WinRM(Http-In) in the Firewall settings因此,请确保在防火墙设置中为 WinRM(Http-In) 配置了所有入站规则

To add to a4aravind's answer,添加到a4aravind的答案,

I was experiencing a similar problem in a Server 2k12 Core environment, but simply adding the firewall rules didn't help.我在 Server 2k12 Core 环境中遇到了类似的问题,但简单地添加防火墙规则并没有帮助。 In my case, the machines that were playing up were on a domain (or had recently been in a domain).就我而言,正在播放的机器在域中(或最近在域中)。 I found that I had to do the following:我发现我必须执行以下操作:

  1. Open regedit.exe and delete HKLM:\\SYSTEM\\Policies\\Microsoft\\Windows Firewall.打开 regedit.exe 并删除 HKLM:\\SYSTEM\\Policies\\Microsoft\\Windows Firewall。 These are the GPO policy settings for Win.这些是 Win 的 GPO 策略设置。 Firewall, and their presence seems to lock the scripts ability to query/change the firewall.防火墙,它们的存在似乎锁定了查询/更改防火墙的脚本能力。 These settings will be recreated by GP when an update happens, just make sure you are fast enough that an update doesn't happen (though the obligatory take a backup statement applies here*).这些设置将在更新发生时由 GP 重新创建,只需确保您的速度足够快,不会发生更新(尽管强制备份声明适用于此处*)。
  2. As suggested by a4aravind, I had to manually add the firewall rules for WinRM.正如 a4aravind 所建议的,我不得不为 WinRM 手动添加防火墙规则。 In my case I found that I had to have both rules within the predefined set - my machines had been configured with the Domain only rule and I had to add the public rule too.在我的例子中,我发现我必须在预定义的集合中拥有这两个规则——我的机器已经配置了仅域规则,我也必须添加公共规则。

Having made these changes I was able to run Enable-PSRemoting, and then gpupdate to reapply the domain firewall rules.进行这些更改后,我可以运行 Enable-PSRemoting,然后使用 gpupdate 重新应用域防火墙规则。

Hopefully that'll help someone in a similar situation.希望这会帮助处于类似情况的人。 A similar error message that I had on some of the machines was "Unable to enable the firewall for WinRM".我在某些机器上遇到的类似错误消息是“无法为 WinRM 启用防火墙”。 I believe this was caused by group policy, and occurs when the message "For your security, some settings are controlled by Group Policy" is shown.我相信这是由组策略引起的,并且在显示消息“为了您的安全,某些设置由组策略控制”时会发生。

Note: In my case, the affected servers had all been built from an image that had previously been joined to the domain and picked up some dodgy GPO policies which messed up WinRM, before being removed from the domain and then added to our catalog.注意:在我的例子中,受影响的服务器都是从一个先前加入域的映像构建的,并在从域中删除然后添加到我们的目录之前,选择了一些搞砸了 WinRM 的狡猾的 GPO 策略。 Which goes to show that you should check your images before pushing out a few dozen server images.这表明您应该在推出几十个服务器镜像之前检查您的镜像。

就我而言,重新启动 Windows 防火墙服务完成了这项工作。

In my case I had to add both "normal" rules as well as "compatiblity" rules:就我而言,我必须同时添加“正常”规则和“兼容性”规则:

Windows Remote Management - Compatibility Mode (HTTP-In)
Windows Remote Management (HTTP-In)

This are 4 rules in total.这总共是4条规则。

Next step is to set Remote Address fields to Any for Public profile rules.下一步是将Remote Address字段设置为Any公共配置文件规则。

That did the trick, I can now modify all WinRM settings.这样就成功了,我现在可以修改所有WinRM设置。

If the effect is not immediate, then select all 4 rules, disable them and enable again, then restart WinRM service.如果效果不是立竿见影的,那就把4条规则全选,禁用再启用,然后重启WinRM服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM