PowerShell小技巧之启动远程桌面连接
以WindowsServer2012R2为例,其实非常简单。先启用远程连接:
(gwmi-classwin32_terminalservicesetting-namespace"root\cimv2\terminalservices").setallowtsconnections(1)
然后再启用几条防火墙规则即可,用PowerShell(需要管理员权限)更显其威武:
PS>Get-NetFirewallRule-NameRemoteDesktop*|selectDisplayName,Direction,Enabled DisplayNameDirectionEnabled --------------------------- 远程桌面-用户模式(TCP-In)InboundFalse 远程桌面-用户模式(UDP-In)InboundFalse 远程桌面-远程监控(TCP-In)InboundFalse PS>Get-NetFirewallRule-NameRemoteDesktop*|Set-NetFirewallRule-Enabledtrue