PowerShell小技巧之添加远程防火墙规则
接着昨天的场景,虽然将WindowsServer2012Core的默认控制台设置成了PowerShell,还启用了远程桌面,但是对于Core版本的服务器来讲,远程桌面形同鸡肋,所以我想启用PowerShell远程访问,在服务器上以管理员权限运行:
Enable-PSRemoting-Force
在尝试建立远程连接时,提示访问被拒绝,此时可能是防火墙问题:我需要使用PowerShell添加PowerShell远程防火墙规则:
New-NetFirewallRule-Namepowershell-remote-tcp-DirectionInbound-DisplayName'PowerShell远程连接TCP'-LocalPort5985-5996-Protocol'TCP' New-NetFirewallRule-Namepowershell-remote-udp-DirectionInbound-DisplayName'PowerShell远程连接UDP'-LocalPort5985-5996-Protocol'UDP'
再次尝试建立连接:
PS>Enter-PSSession-ComputerName192.168.1.15-Credentialadministrator [192.168.1.15]:PSC:\Users\Administrator\Documents>hostname AD-2012
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下