This script was created to gather a list of IP addresses from a remote server and update a firewall rule that will allow those IP addresses access to my server via Remote Desktop:

Powershell script

$tempFileLocation = "c:\\temp\\AllowedIpAddresses.txt"
$firewallRuleName = "NAME OF FIREWALL RULE"

$url = "https://MYSITE.COM/ListOfIps.txt"
$useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36"


Invoke-WebRequest -URI $url -OutFile $tempFileLocation -UserAgent $useragent

$ipAddresses = Get-Content $tempFileLocation
Get-NetFirewallRule -DisplayName $firewallRuleName | Get-NetFirewallAddressFilter |  Set-NetFirewallAddressFilter -LocalAddress Any -RemoteAddress $ipAddresses