首页 > 开发 > PowerShell > 正文

PowerShell小技巧之添加远程防火墙规则

2020-03-26 19:18:03
字体:
来源:转载
供稿:网友

接着昨天的场景,虽然将Windows Server 2012 Core的默认控制台设置成了PowerShell,还启用了远程桌面,但是对于Core版本的服务器来讲,远程桌面形同鸡肋,所以我想启用PowerShell远程访问,在服务器上以管理员权限运行:

Enable-PSRemoting -Force

在尝试建立远程连接时,提示访问被拒绝,此时可能是防火墙问题:我需要使用PowerShell添加PowerShell远程防火墙规则:

New-NetFirewallRule -Name powershell-remote-tcp -Direction Inbound -DisplayName 'PowerShell远程连接 TCP' -LocalPort 5985-5996 -Protocol 'TCP'New-NetFirewallRule -Name powershell-remote-udp -Direction Inbound -DisplayName 'PowerShell远程连接 UDP' -LocalPort 5985-5996 -Protocol 'UDP'

再次尝试建立连接:

PS> Enter-PSSession -ComputerName 192.168.1.15 -Credential administrator[192.168.1.15]: PS C:/Users/Administrator/Documents> hostnameAD-2012

 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表