Powershell 远程连接ARM Windows Server VM 并关闭 Firewall
准备环境:Azure ARM Windows Server 2008 R2 机器
1.登陆机器查看防火墙,是开着的

2.查看机器的监听端口,发现没有Powershell远程管理对应的端口5985或5986 【5985(http) / 5986(https) 】

3.需要在Server机器上 Enable-PSRemoting
PS C:\Users\stone> Enable-PSRemoting
WinRM 快速配置
正在运行命令“Set-WSManQuickConfig”,以使该计算机能够通过 WinRM 服务进行远程管理。
其中包括:
1. 启动或重新启动(如果已启动) WinRM 服务
2. 将 WinRM 服务类型设置为自动启动
3. 创建一个侦听器以接受任意 IP 地址上的请求
4. 对 WS-Management 流量启用防火墙例外(仅适用于 http)。
是否继续?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 挂起(S) [?] 帮助 (默认值为“Y”):
在此计算机上,WinRM 已设置为接收请求。
WinRM 已经进行了更新,以用于远程管理。
在 HTTP://* 上创建 WinRM 侦听程序接受 WS-Man 对此机器上任意 IP 的请求。
WinRM 防火墙异常已启用。
已配置 LocalAccountTokenFilterPolicy 以远程向本地用户授予管理权限。
确认
是否确实要执行此操作?
对目标“未找到会话配置“Microsoft.PowerShell32”。正在运行命令“Register-PSSessionConfiguration Microsoft.PowerShell32
-processorarchitecture x86 -force”以创建“Microsoft.PowerShell32”会话配置。这将会重新启动 WinRM
服务。”执行操作“正在注册会话配置”。
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 挂起(S) [?] 帮助 (默认值为“Y”):
4.再次查看机器的监听端口,发现Powershell远程管理对应的端口5985已经被监听了

5.在Portal界面添加允许5985端口的NSG规则,并测试该端口的连通性


6.尝试Powershell远程登陆虚拟机,发现会出现如下报错:
PS C:\Users\he.liming> Enter-Pssession -ComputerName "40.*.*.*" -port 5985 -Credential VMAccountName
Enter-Pssession : Connecting to remote server 40.*.*.* failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set Trusted
Hosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-Pssession -ComputerName "40.*.*.*" -port 5985 -Credential stone
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (40.125.160.63:String) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
7.需要将Server端IP地址添加到Client机器的TrustedHosts列表下
PS C:\Windows\system32> Set-Item wsman:\localhost\Client\TrustedHosts -value 40.125.160.63
WinRM Security Configuration.
This command modifies the TrustedHosts list for the WinRM client. The computers in the TrustedHosts list might not be
authenticated. The client might send credential information to these computers. Are you sure that you want to modify
this list?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
8.重新使用Powershell连接虚拟机,登陆成功
PS C:\Users\he.liming> Enter-Pssession -ComputerName "40.125.160.63" -port 5985 -Credential VMAccountName
[40.125.160.63]: PS C:\Users\stone\Documents>
9.使用如下命令关闭防火墙
PS C:\Users\stone\Documents> netsh advfirewall set allprofiles state off
10.再次查看防火墙,已经关闭

备注:Windows Server 2012 R2的机器开启Powershell远程连接的方法,与上面的操作大同小异,需要注意的是Windows Server 2012 R2机器默认情况下5985的端口是监听着的

Powershell 远程连接ARM Windows Server VM 并关闭 Firewall的更多相关文章
- SQL Server 2014数据库开启远程连接(Windows Server 2016)
1.打开SQL SERVER 配置管理器 2. 设置防火墙的入站规则 3.使用Navicat Premium连接SQL Server
- 使用 Powershell 远程连接 windows server
使用 Powershell 远程连接 windows server Intro 最近我们的开发环境增加了一个 windows 服务器,没有界面的,不能直接远程桌面连上去管理,需要使用 Powershe ...
- powershell远程连接
最近因为工作的需要看了看powershell相关的知识,个人总结了一点有关于powershell远程连接需要做的步骤,希望对别人有所帮助. 使用powershell远程连接,需要进行 设备的配置: 1 ...
- Windows Server 2008中关闭事件跟踪程序的方法
Windows Server 2008跟Windows Server 2003一样,在关机的时候会弹出一个“关闭事件跟踪程序”窗口,当然微软这么做是处于安全的考虑啦,但是如果我们只是个人用用的话,那就 ...
- 远程链接 aws Windows Server 2016 Base Nano
第一次接触Windows Server 2016 Base Nano,平时工作中或者自己私下使用win的服务器都是带桌面版本的 而这次在aws一不小心开了一台Nano服务,刚开始我都不知道这个是什么玩 ...
- asp.net mvc项目远程发布到windows server服务器
文章参考 自学MVC看这里——全网最全ASP.NET MVC 教程汇总 图文详解远程部署ASP.NET MVC 5项目 配置Web部署处理程序 设备及环境 一台装有windows server 201 ...
- 使用PowerShell远程连接WinServer
最近做一个项目后台,涉及到多台服务器,当程序更新的时候,由于用的是WinServer,无法像Linux使用SSH批量更新,用Windows的mstsc的远程一个一个连接又太麻烦了.查找了一下资料,发现 ...
- iOS-Mac远程连接控制Window【苹果电脑远程连接控制Windows电脑】
用Mac电脑时想远程控制Windows电脑,摸索了半天搞定了 1.下载Mac远程控制安装包:http://pan.baidu.com/s/1o7ZsDQy 提取密码:r2ja 2.安装好之后打开,就 ...
- PowerShell远程连接主机进行会话
Get-ExecutionPolicy #脚本的执行策略set-ExecutionPolicy 枚举值 不同的策略,执行脚本的权限不同 允许开启远程 Enable-PSRemoting 添加域账户或者 ...
随机推荐
- JAVA编程入门
java最早是由Sun公司基于C++开发而成的新一代编程语言也是现行下的主流行编程语言,其原始的主要用于嵌入式开发.java的第一个版本为JDK1.0,到2017年已经升级到JAK1.9版本.java ...
- http服务详解(2)——httpd2.2的配置文件常见设置
摘要:一个服务的配置文件非常重要,弄懂配置文件是熟练掌握服务的必要前提. 一.httpd-2.2常见文件介绍 (1)配置文件: 主配置文件尽量别改,改自己的子配置文件 /etc/httpd/conf/ ...
- 博客收藏--sailing的博客
http://blog.sina.com.cn/sailingxr free:这个博客主页的内容不错 PC的足迹 arm与x86 浅谈PCIe体系架构 浅谈cache memory
- 【前端】windows64位必备软件清单
目录 一.前言 二.日常必备 三.前端相关 四.个人习惯 一.前言 重做系统以后,安装各种软件就是挺烦人的一件事. 特地整理成文章,并且将相关软件上传到了百度网盘,省的以后再各种找资源了. 百度网盘下 ...
- 【ASP.NET MVC 学习笔记】- 03 Razor语法
本文参考:http://www.cnblogs.com/willick/p/3224144.html 1.Razor语句以@开头. 2.每个View都有自己的Model属性,可通过@Model调用.语 ...
- 聊聊Java的字节码
本文为作者原创,转载请注明出处(http://www.cnblogs.com/mar-q/)by 负赑屃 巴山楚水凄凉地,二十三年弃置身.怀旧空吟闻笛赋,到乡翻似烂柯人.沉舟侧畔千帆过,病树前头万木春 ...
- Android开发中的OpenCV霍夫直线检测(Imgproc.HoughLines()&Imgproc.HoughLinesP())
本文为作者原创,转载请注明出处(http://www.cnblogs.com/mar-q/)by 负赑屃 //2017-04-21更新: 很多网友希望能得到源码,由于在公司做的,所以不太方便传出来 ...
- 在mac OS10.10下安装 cocoapods遇到的一些问题
今天有个朋友问了我一个问题:为什么我安装cocoapods不成功,报 sh: line 1: 997 Abort trap: 6 /Applications/Xcode.app/Contents/De ...
- python爬虫如何入门
学爬虫是循序渐进的过程,作为零基础小白,大体上可分为三个阶段,第一阶段是入门,掌握必备的基础知识,第二阶段是模仿,跟着别人的爬虫代码学,弄懂每一行代码,第三阶段是自己动手,这个阶段你开始有自己的解题思 ...
- 使用Apache Commons Email 发生邮件
Apache Commons Email的Maven依赖 <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-e ...