Use PowerShell to update your domain’s DNS dynamically with Loopia.
The script
#Your info goes here
#The domain name to update
$hostname = "yourdomain.com"
#Username and password for your Loopia Customer Zone account (not the domain name)
$user = "your-customerzone-username"
$pwd = "your-customerzone-password"
#Force TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#Get a page with your current IP
$MyIpPage = Invoke-WebRequest "https://dyndns.loopia.se/checkip"
#Make sure we got a IP back in the response
If ($MyIpPage -match "(?:[0-9]{1,3}.){3}[0-9]{1,3}")
{
$myIp = $Matches[0]
#Create a set of credentials
$secpasswd = ConvertTo-SecureString $pwd -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
#Build up the URL
$url = "https://dyndns.loopia.se/?hostname=$hostname&myip=$myIp"
#Invoke the URL
$resp = Invoke-WebRequest -Uri $url -Credential $mycreds
$resp.Content #Expected answers that I found "good","nochg","nohost","badauth","notfqdn"
}
Else
{
#fake response if we didn't get any IP
"NoDynIP"
}
Adapting the script for your account
Important: You always log in with the username and password for your Loopia Customer Zone account, regardless of which domain name you want to update. The domain name is not your username.
- Replace yourdomain.com with the domain name you want to set an IP address for.
- Replace your-customerzone-username with your Loopia Customer Zone username.
- Replace your-customerzone-password with your Customer Zone password.
To update several domain names, run the script once per domain name with a different value for $hostname, but with the same Customer Zone username and password.
Credit to Pär at Powershell.today for the script!