Powershell 远程管理
一直使用 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 远程管理的更多相关文章
- 【原创】开启PowerShell远程管理
		
非域网络,开启PowerShell远程管理,命令如下: 以下操作,PS命令窗口,必须都以管理员省份执行. Step 1: 机器A和B,分别开启PowerShell远程管理服务A = 192.168.3 ...
 - PowerShell 远程管理之  about_Remote_Troubleshooting
		
主题 about_Remote_Troubleshooting 简短说明 说明如何解决 Windows PowerShell 中的远程操作的问题. 详细说明 本节描述您在使用 Windows Powe ...
 - 通过winrm使用powershell远程管理服务器
		
原文地址 在Linux中,我们可以使用安全的SSH方便的进行远程管理.但在Windows下,除了不安全的Telnet以外,从Windows Server 2008开始提供了另外一种命令行原创管理方式, ...
 - 使用 PowerShell 远程管理
		
要求 PowerShell 版本要求至少是2.0版本以上,目前PowerShell 2.0 支持最低的操作系统版本为Windows XP.本次操作使用的是 PowerShell 5.1 请使用管理员身 ...
 - powershell远程管理服务器磁盘空间的实现代码
		
一.启用远程管理 1.将管理服务器的trusthost列表改为* 运行Set-item wsman:localhostclienttrustedhosts ?value * 2.在远程服务器上运行En ...
 - 使用Windows Azure PowerShell远程管理Windows Azure虚拟机
		
对于Windows Azure,如果你还在使用windowsazure.com门户来管理虚拟机,那就显得不怎么高上大了.Windows Azure PowerShell 是一个功能强大的脚本环境,可用 ...
 - 第三章 用 PowerShell 进行远程管理(remoting)
		
第三章 用 PowerShell 进行远程管理(remoting) PowerShell V2 引进了一项强大的新技术,远程(remoting),PowerShell V3 进行了完善和扩展.主要基于 ...
 - Powershell 远程连接ARM Windows Server VM 并关闭 Firewall
		
准备环境:Azure ARM Windows Server 2008 R2 机器 1.登陆机器查看防火墙,是开着的 2.查看机器的监听端口,发现没有Powershell远程管理对应的端口5985或59 ...
 - [转帖]Ansible批量远程管理Windows主机(部署与配置)
		
2018-09-12 12:04:42 https://blog.51cto.com/7424593/2174156 一.测试环境介绍 Ansible管理主机: 系统: CentOS6.8 IP ...
 
随机推荐
- oracle 查看表空间的脚本
			
SELECT upper(f.tablespace_name) "表空间名", d.Tot_grootte_Mb "表空间大小(M)", d.Tot_groot ...
 - hdu 4388 Stone Game II sg函数 博弈
			
Stone Game II comes. It needs two players to play this game. There are some piles of stones on the d ...
 - Binary Indexted Tree 树状数组入门
			
感谢http://www.cnblogs.com/xudong-bupt/p/3484080.html 树状数组(BIT)是能够完成下述操作的数据结构: 给定一初始值全为零的数列a1,a2a,a3.. ...
 - 走近Docker
			
一个容器实际上就是运行在宿主机上的一个进程,这个进程以及子进程会认为自己运行在一个独立的世界里. Docker相对于其他虚拟化技术的优势在于:创建.删除容器速度快,容器运行占用开销非常小.而相对于其他 ...
 - [BZOJ1018][SHOI2008]堵塞的交通traffic  线段树维护连通性
			
1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec Memory Limit: 162 MB Submit: 3795 Solved: 1253 [Sub ...
 - (10)ERStudio
			
1.外键 https://jingyan.baidu.com/article/f79b7cb37e9d219144023ea6.html 第一个图标:Identifying Relationship ...
 - Codeforces Round #448 (Div. 2) B. XK Segments【二分搜索/排序/查找合法的数在哪些不同区间的区间数目】
			
B. XK Segments time limit per test 1 second memory limit per test 256 megabytes input standard input ...
 - Codeforces Gym 101775D Mr. Panda and Geometric Sequence(2017-2018 ACM-ICPC Asia East Continent League Final,D题,枚举剪枝)
			
题目链接 ECL-Final 2017 Problem D 题意 给定$2*10^{5}$组询问,每个询问求$l$到$r$之间有多少个符合条件的数 如果一个数小于等于$10^{15}$, 并且能被 ...
 - CodeChef  February Challenge 2018  Broken Clock (三角函数推导 + 矩阵快速幂)
			
题目链接 Broken Clock 中文题面链接 令$cos(xα) = f(x)$ 根据三角函数变换公式有 $f(x) = \frac{2d}{l} f(x-1) - f(x-2)$ 我们现在 ...
 - 树链剖分【P3833】 [SHOI2012]魔法树
			
Description Harry Potter 新学了一种魔法:可以让改变树上的果子个数.满心欢喜的他找到了一个巨大的果树,来试验他的新法术. 这棵果树共有N个节点,其中节点0是根节点,每个节点u的 ...