PowerShell for DDNS (DynDNS.org)

You may also like...

6 Responses

  1. Jay says:

    Hey lewis, this is exactly what I needed but I’m not familiar with powershell so I was wondering if I could pick your brain a bit. Especially the part where you are getting the credentials for the update. Not sure what to do about the .xml part.

    Please e-mail me if you have time to discuss further.

    Thanks

  2. Jay says:

    typed my e-mail incorrectly… duh!

  3. Lewis says:

    Hi Jay, I appreciate PowerShell can be very daunting to a new user but fear not, it’s fairly simple.

    The script itself is executed as a specific user on a specific computer so first experiment by simply opening the PowerShell console. You can use the Integrated Scripting Environment (ISE) or the console, but starting new, I would recommend you use the ISE.

    At the prompt, type Get-Credential (uppercase or lowercase doesn’t matter) and press Enter. You’ll be prompted to enter a username and password. Type in anything you want (you’re testing) and press enter or click OK and you’ll see something appear on the command line with the username you entered and a value System.Security.SecureString. What you’ve done is created an “object”. Now, instead of sending that object to the console, you use the “pipe” (vertical character) to “pipe” the object to another command called Export-Clixml.

    Do the same thing but this time type:

    Get-Credential | Export-Clixml "mypassword.xml"
    

    Enter your username and password (again, it can be anything at all, you’re only testing) and press Enter.

    A file called mypassword.xml will be saved in to the path you are curently in – if you haven’t changed it since opening ISE, this will be C:\Users\[username]

    Navigate to that path and you’ll see the file. Open it in Notepad and you’ll see your username and lots of other XML. The “password” you entered is encrypted and only readable by the user who created it.

    Now, applying what you just learned, and using the commands from my script, execute:

    Get-Credential | Export-Clixml "DynDNS-$env:COMPUTERNAME.xml"
    

    In the prompt, enter the username and password you would use to log on to DynDNS and press Enter. A file called DynDNS-[The Name Of Your PC].xml will be created. Keep this XML file with the script (on the same PC you used when creating it!) and then run the script, not forgetting to update the host names you want to update with your current IP.

    Hope that helps!

  4. TxF says:

    Great post, thank you for sharing. I needed a script to send my local IP (not internet-facing IP) to the service and this worked great with a few small tweaks.

  5. Hemant Patel says:

    Hey lewis, this is exactly what I need. But I keep getting “badauth” error everytime I send RestMethod, have double checked the username and password. If I copy the URL into a web browser it works fine.

    Please e-mail me if you have time to discuss further.

    Thanks

  6. Lewis says:

    Hemant, you may need to provide your credentials in a specific format. For example if you’re using only a friendly user name, try using an email address instead or vice versa. There is a small possibility that Dyn have changed how you interact with their Rest endpoint but I’d be surprised if that were the case. It’s almost definitely just the username or password being incorrect.

Discover more from lewisroberts.com

Subscribe now to keep reading and get access to the full archive.

Continue reading