Description :

Nowadays most of the DDNS Providers don’t provide their DDNS service for free anymore. If you don’t want to pay for this service, this is your solution to get notified about your IP Address change at home.

In this tutorial I will quickly explain the script and the logic behind that. To get notified about your IP Address change you will need an Gmail Account, Google App Password and the Script. The script needs to be scheduled on your home PC over the “Task Scheduler”.

In this tutorial I will not cover how to schedule a Powershell Script in “Task Scheduler” and how to get an “Google App Password” for Google SMTP Server. These information can be found easily in search engines.

The Script can be downloaded from the Technet Script Gallery too.

Powershell DDNS Service “Get notified about your Public IP Address via E-Mail”

The Powershell Script is as follows :

# DDNSPublicIPNotifier.ps1
# Version 1.0
# Date: 12/01/2019
# Author: Cengiz KUSKAYA (www.Kuskaya.Info)
# Description: Get notified about your Public IP change via e-mail over Google SMTP
# In this part we are basically saving the date, google account which should send the e-mail via Google SMTP Server and the recipient into variables.Furthermore we get the Public IP Address via the Invoke-WebRequest cmdlet and save it into the $MyIP variable.
$TimeDate = Get-Date -Format g
$EmailFrom = “”
$EmailTo = “”
$MyIP = Invoke-WebRequest -UseBasicParsing -Uri

# The Invoke-WebRequest cmdlet collects a few additional information therefore with the ($MyIP).Content I only pick the Public IP and save it into the $RAWUpToDatePublicIP variable which I will use later. Furthermore I prepare my E-Mails Subject and Body fields.
$RAWUpToDatePublicIP = ($MyIP).Content
$Subject = “My Actual IP Address – $TimeDate$MyIP
$Body = “$TimeDate`n$MyIP

# Most of you will wonder why I am saving the IP Address into an Text file and comparing it every time before sending the e-mail over Google SMTP Server. Even if you are able to send 3000 e-mails for free over Google SMTP Server if you send the same e-mail content again and again to the same e-mail recipient over Google SMTP, Google can find this e-mail as suspicious and stop sending your e-mails. To prevent this I am only sending the e-mail if any change happens.
$PubliIPFilePath = “D:\Public-IP.txt”
if (-Not(Test-Path -Path $PubliIPFilePath -PathType leaf))
New-Item -Path “D:\” -Name “Public-IP.txt” -ItemType “file” -Value “88.888.888.88”
$TextFileContent = Get-Content $PubliIPFilePath
if (-Not($RAWUpToDatePublicIP -eq $TextFileContent))
($MyIP).Content >D:\Public-IP.txt

# In our last part we are basically sending the e-mail.
$SMTPServer = “”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“OnlyGmailUserName”, “YourGoogleAppPassword”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Hope it helps !