Error updating dynamic dns entry
This is the output from the script: And now the resulting zone configuration shows the new updated records as per our CSV file: While this may be a very simple example, it is meant to be a starting point to show you how to make the best of a situation where there is not a native Power Shell Cmd Let.Being able to use hybrid scripting tools and techniques is a great thing to have in your toolkit of skills.
However, if you have registered the domain name with another registrar you will need to update the nameservers with that company.
Because this is not a commonly occurring task, there are no native Power Shell Cmd Lets to do this.
What we can do however is get the best of breed by using Power Shell to parse a file and craft the command line to use the Microsoft DNSCMD command line tool.
The script logic is fairly simple: I haven’t added any fancy logging or anything, but there is some Write-Host Cmd Lets used to output the commands to screen so that you can ensure that they are coming out as expected. Because we are using the Invoke-Expression Cmd Let to launch the DNSCMD executable, we don’t have the luxury of a -What If option.
You can comment out the Invoke-Expression lines and run using just the Write-Host output as a sanity check on your structure. The script can be downloaded at my Tech Net Gallery here: # Environment Setup $DNSServer = “DC1” $DNSZone = “corp.discoposse.com” $Input File = “dnsrecords.csv” # Read the input file which is formatted as name,type,address with a header row $records = Import-CSV $Input File # Now we loop through the file to delete and re-create records # DNSCMD does not have a modify option so we must use /Record Delete first followed by a /Record Add For Each ($record in $records) So let’s run the script and see the results.Secure Key Based Updates Our secure DUC does not resend your No-IP credentials each time it sends an IP address update, instead it sends a unique key for username and password for your specific Dynamic Update Client.