Skip to content

Instantly share code, notes, and snippets.

@SevenLayerJedi
Created December 21, 2018 14:49
Show Gist options
  • Save SevenLayerJedi/7f1c362edb84c49ed0d6944e54219fab to your computer and use it in GitHub Desktop.
Save SevenLayerJedi/7f1c362edb84c49ed0d6944e54219fab to your computer and use it in GitHub Desktop.
# Commands to allow/disallow through Windows Firewall
# NETSH
netsh firewall set service type = remotedesktop mode = enable
# Registry
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
# PowerShell
$FireWall = New-Object -comObject HNetCfg.FwPolicy2
$EnableRules = $FireWall.rules | Where-Object {$_.LocalPorts -like "*3389*" -and $_.Profiles -eq "3"}
ForEach ($Rule In $EnableRules){($Rule.Enabled = "True")}
# Where 1 (Domain networks) + 2 (Private networks) = 3
# Figured out what the properties and methods are
$FireWall | Get-Member
$Rules | Get-Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment