Created
July 31, 2014 21:11
-
-
Save jbfriedrich/dfd85370ad15fd510265 to your computer and use it in GitHub Desktop.
Only allow RDP from whitelisted IPs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set execution policy | |
# AllSigned : Every script must bear a valid signature | |
# RemoteSigned : Must be signed by a trusted publisher (for example Microsoft) | |
# Unrestricted : No restrictions whatsoever, every script can run | |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned | |
# Whitelisted IPs which are allowed to use the services on this host | |
$whitelistIPs = "8.8.8.8", "127.0.0.1" | |
# DisplayNames for the firewall rules for Remote Desktop | |
$remoteDeskopFwRules = "Remote Desktop - User Mode (TCP-In)", "Remote Desktop - User Mode (UDP-In)" | |
foreach ($rule in $remoteDeskopFwRules) { | |
# This will only configure and enable the Firewall ports. The service needs to be (re-)started separately! | |
Set-NetFireWallRule -DisplayName $rule -Enabled True -Direction Inbound -RemoteAddress $whitelistIPs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment