使用Powershell远程管理Windows Server(WinRM)
来源:互联网 发布:重庆江津网络花店 编辑:程序博客网 时间:2024/05/18 01:26
在Linux中,我们可以使用安全的SSH方便的进行远程管理。但在Windows下,除了不安全的Telnet以外,从Windows Server 2008开始提供了另外一种命令行原创管理方式,那就是基于PowerShell的WinRM。
下面就介绍下如何使用WinRM,客户端和服务端必须为同一域:
1、在Windows Server 2008上配置WinRM:
C:\Windows\system32> winrm quickconfig
在此计算机上,WinRM 已设置为接收请求。
WinRM 没有设置成为了管理此计算机而允许对其进行远程访问。
必须进行以下更改:
在 HTTP://* 上创建 WinRM 侦听程序接受 WS-Man 对此机器上任意 IP 的请求。
进行这些更改吗[y/n]? y
WinRM 已经进行了更新,以用于远程管理。在 HTTP://* 上创建 WinRM 侦听程序接受 WS-Man 对此机器上任意 IP 的请求。
2、开启防火墙命令或者直接关闭防火墙:
C:\Windows\system32>netsh advfirewall firewall set rule group="Windows 远程管理" new enable=yes
3、使用PowerShell连接远程服务器:
PS C:\Users\WW-PC>Enter-PSSession -computer 服务器名或者IP
Enter-PSSession : 连接到远程服务器失败,错误消息如下: WinRM 客户端无法处理该请求。如果身份验证方案与 Kerberos 不同,或
者客户端计算机未加入到域中, 则必须使用 HTTPS 传输或者必须将目标计算机添加到 TrustedHosts 配置设置。 使用 winrm.cmd 配
置 TrustedHosts。请注意,TrustedHosts 列表中的计算机可能未经过身份验证。 通过运行以下命令可获得有关此内容的更多信息: wi
nrm help config。 有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
所在位置 行:1 字符: 16
+ Enter-PSSession <<<<? 192.168.3.1 -Credential abc\administrator
+ CategoryInfo : InvalidArgument: (192.168.3.1:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
网上一般都是说要添加一个TrustedHosts表,相当于一个信任列表。
执行如下命令,将IP为192.168.3.*的主机都加入信任列表
Set-Item wsman:\localhost\Client\TrustedHosts -value 192.168.3.*
注意这个命令需要在 客户端上执行 不是在服务端执行 且客户端需要已管理员权限执行,这一点许多教程没有说,走了不少弯路。
之后再用 Enter-PSSession 192.168.3.1 -Credential abc\administrator 命令就可以完成连接了,没有域的话就直接写用户名。
顺便提一下,如果你想在任何时间禁用WinRM,你可以使用这样的命令:
winrm delete winrm/config/listener?IPAdress=*+Transport=HTTP
- 使用Powershell远程管理Windows Server(WinRM)
- 用Powershell远程管理Windows Server(WinRM)
- Windows 远程管理WinRM
- Windows 远程管理WinRM
- 初探 Windows PowerShell 2.0 远程管理应用
- Windows Server 2008中PowerShell的使用
- 通过PowerShell Server使用ssh连接windows
- powershell 1.2 windows-server
- 跨平台PowerShell如何远程管理Linux/Mac/Windows?
- PowerShell 2.0远程管理开发使用CredSSP处理多跳授权
- PowerShell中远程管理服务
- Powershell 远程管理Exchange
- powershell远程管理服务器磁盘空间
- Windows Server 2008 安装powershell
- Windows PowerShell 使用SDKMAN
- Windows PowerShell 使用SDKMAN
- 第三章 用 PowerShell 进行远程管理(remoting)
- PowerShell 2.0远程管理之隐式远程管理
- How to Setup Load Balance in SharePoint 2010 Farm
- 在线手把手一对一教学,一小时你愿意出多少血?
- 尝试写个爬虫(2)
- Python的学习(二十七)---- 遍历目录树
- 二维数组转换成为DataTable
- 使用Powershell远程管理Windows Server(WinRM)
- Ubuntu下好用的轻量级代码编辑器—Scribes
- CentOS 重启网卡提示:/org/freedesktop/NetworkManager/ActiveConnection/(n)
- Android项目实战--手机卫士02--与服务器交互
- DB2_备份恢复(离线&在线)
- 退出python shell
- Android程序中动态添加Button
- Android---ASE---脚本语言研究1--perl
- 原始字符串