一直使用 mstsc,为了防止墨菲定律,准备一些备用方案

环境,win10 to win12

winrm是windows 一种方便远程管理的服务;

首先要开启winrm service,便于在日常工作中,远程管理服务器,或通过脚本,同时管理多台服务器,来提高工作效率;

运行cmd
1 winrm service 默认都是未启用的状态,先查看状态;如无返回信息,则是没有启动;

winrm enumerate winrm/config/listener

如果没启动,则打开 计算机管理>服务启用 WRM服务 并设置为自动运行

2 针对winrm service 进行基础配置:

winrm quickconfig

3 查看winrm service listener:

winrm e winrm/config/listener

4 为winrm service 配置auth:

winrm set winrm/config/service/auth @{Basic="true"}

5 为winrm service 配置加密方式为允许非加密:

winrm set winrm/config/service @{AllowUnencrypted="true"}

6 至此,winrm service 已经启用,可以正常使用;

服务端:运行 PowerShell

开打远程管理  Enable-PSRemoting –Force

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。 PS C:\Users\Administrator> Enable-PSRemoting –Force
在此计算机上设置了 WinRM 以接收请求。
在此计算机上设置了 WinRM 以进行远程管理。
PS C:\Users\Administrator>

客户端:连接  PowerShell

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。 PS C:\Windows\system32> cd wsman::localhost\client
PS Microsoft.WSMan.Management\WSMan::localhost\Client> Set-Item TrustedHosts “218.2.2.18” WinRM 安全配置。
此命令修改 WinRM 客户端的 TrustedHosts 列表。TrustedHosts
列表中的计算机可能不会经过身份验证。该客户端可能会向这些计算机发送凭据信息。是否确实要修改此列表?
[Y] 是(Y) [N] 否(N) [S] 暂停(S) [?] 帮助 (默认值为“Y”): y
PS Microsoft.WSMan.Management\WSMan::localhost\Client> ls WSManConfig:Microsoft.WSMan.Management\WSMan::localhost\Client Type Name SourceOfValue Value
---- ---- ------------- -----
System.String NetworkDelayms
System.String URLPrefix wsman
System.String AllowUnencrypted false
Container Auth
Container DefaultPorts
System.String TrustedHosts 218.2.2.18 PS Microsoft.WSMan.Management\WSMan::localhost\Client> Enter-PSSession -ComputerName 218.2.2.18 –Credential Administ
rator
[218.2.2.18]: PS C:\Users\Administrator\Documents> d:
[218.2.2.18]: PS D:\> dir

 客户端退出 Exit-Pssession

 Exit-Pssession

如果要使用Hyper-V管理,还需要使用Selfssl.exe生成证书

您可以通过检查证书列表来验证任何服务器上的证书。
打开证书列表
开始菜单上,单击运行,然后键入mmc。单击Enter。这将启动Microsoft管理控制台(MMC)。
在控制台中,单击“ 文件 ”菜单,然后单击“ 添加/删除管理单元”。
在“ 添加/删除管理单元”窗口中,单击添加按钮。
在管理单元列表中,选择证书,然后单击添加
在“ 证书管理单元”窗口中,选择计算机帐户,然后单击下一步
在“ 选择计算机 ”窗口中,选择“ 本地计算机”或“ 其他计算机”,然后单击“完成”。这会将“证书管理单元”添加到列表中。关闭窗口。
在“ 添加/删除管理单元”窗口中,单击“确定”。这会将证书管理单元添加到mmc控制台。
展开“ 证书”节点以查看不同类型的证书。
使用Selfssl工具创建的自我信任证书将显示在个人和受信任的根证书颁发机构 文件夹中的证书文件夹中。它将具有您在/ N:CN中指定的名称。

打开MMC 找到刚才的证书,复制证书 详细信息里面的 指纹

执行CMD
C:\Users\Administrator> winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="192.168.1.102";CertificateThumbprint="‎ eb 5d 5d 5d 89 5d 5d 5d 5d 5d 5d ac 5d 5d 5d 5d 5d aa 5d 5d"}
添加对https 的监听,以及添加证书指纹.

执行 Winrm enumerate winrm/config/listener  也可以确认添加是否成功显示:

说明已经正确添加了SSL证书.再次返回到客户端进行连接:
Powershell
Enter-PSSession -ComputerName 192.168.1.102 –Credential  Administrator –UseSSL

参考:https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.core/Exit-PSSession

Powershell 远程管理的更多相关文章

  1. 【原创】开启PowerShell远程管理

    非域网络,开启PowerShell远程管理,命令如下: 以下操作,PS命令窗口,必须都以管理员省份执行. Step 1: 机器A和B,分别开启PowerShell远程管理服务A = 192.168.3 ...

  2. PowerShell 远程管理之 about_Remote_Troubleshooting

    主题 about_Remote_Troubleshooting 简短说明 说明如何解决 Windows PowerShell 中的远程操作的问题. 详细说明 本节描述您在使用 Windows Powe ...

  3. 通过winrm使用powershell远程管理服务器

    原文地址 在Linux中,我们可以使用安全的SSH方便的进行远程管理.但在Windows下,除了不安全的Telnet以外,从Windows Server 2008开始提供了另外一种命令行原创管理方式, ...

  4. 使用 PowerShell 远程管理

    要求 PowerShell 版本要求至少是2.0版本以上,目前PowerShell 2.0 支持最低的操作系统版本为Windows XP.本次操作使用的是 PowerShell 5.1 请使用管理员身 ...

  5. powershell远程管理服务器磁盘空间的实现代码

    一.启用远程管理 1.将管理服务器的trusthost列表改为* 运行Set-item wsman:localhostclienttrustedhosts ?value * 2.在远程服务器上运行En ...

  6. 使用Windows Azure PowerShell远程管理Windows Azure虚拟机

    对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了.Windows Azure PowerShell 是一个功能强大的脚本环境,可用 ...

  7. 第三章 用 PowerShell 进行远程管理(remoting)

    第三章 用 PowerShell 进行远程管理(remoting) PowerShell V2 引进了一项强大的新技术,远程(remoting),PowerShell V3 进行了完善和扩展.主要基于 ...

  8. Powershell 远程连接ARM Windows Server VM 并关闭 Firewall

    准备环境:Azure ARM Windows Server 2008 R2 机器 1.登陆机器查看防火墙,是开着的 2.查看机器的监听端口,发现没有Powershell远程管理对应的端口5985或59 ...

  9. [转帖]Ansible批量远程管理Windows主机(部署与配置)

    2018-09-12 12:04:42 https://blog.51cto.com/7424593/2174156 一.测试环境介绍 Ansible管理主机: 系统:   CentOS6.8 IP ...

随机推荐

  1. Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  2. code forces 990C

    http://codeforces.com/contest/990/problem/C C. Bracket Sequences Concatenation Problem time limit pe ...

  3. mysql 游标的嵌套使用示例

    BEGIN DECLARE trainee_no_value BIGINT (20); -- 学员编号 DECLARE pay_no_value BIGINT (20); -- 交费序号 DECLAR ...

  4. 限制MYSQL从服务器为只读状态

    修改全局变量的方法有两种,第一种是修改配置文件,第二种是SQL语句设置全局变量的值.(可以参考:http://www.cnblogs.com/qlqwjy/p/8046592.html) 0.简介: ...

  5. glRotatef 转动方向

    http://blog.sina.com.cn/s/blog_3c6889fe0100qko6.html glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLf ...

  6. win7兼容visual studio 2005 的方法

    http://blog.sina.com.cn/s/blog_74d572890100xv7p.html 今天花了4个小时,结合网上的介绍,本人终于找到了一个可以在win7环境下运行visual st ...

  7. 基于UDP高性能传输协议UDT doc翻译(一)

    原文转自:http://hi.baidu.com/doodlezone/item/74a203155efe26dbbf9042dd                  UDT文档阅读理解 一.  概述 ...

  8. jdbc连接警告不安全

    Mon Jun 11 10:46:26 CST 2018 WARN: Establishing SSL connection without server's identity verificatio ...

  9. 负载均衡技术之-lvs

    LVS简介 Internet的快速增长使多媒体网络服务器面对的访问数量快速增加,服务器需要具备提供大量并发访问服务的能力,因此对于大负载的服务器来讲, CPU.I/O处理能力很快会成为瓶颈.由于单台服 ...

  10. hdu 1546(dijkstra)

    Idiomatic Phrases Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O ...