hi there, i made a program about a mounth ago which updated my A Records for my DNS server, this was great as at the time i only had one DNS server, and had a DYnamic IPv4 public adress
however i now have two DNS servers -one Primary, one Secondary- replicating the primary
however when updating my script no longer works, as i also now have 2 web servers so2 A records.
here is my original code.
import-module -name DnsServer $ip = (Invoke-WebRequest ip.mikster22.co.uk/ip.php).Content $newip = $ip.TrimEnd( ) $oldobj = get-dnsserverresourcerecord -zonename "mikster22.co.uk" -rrtype "A" -node $newobj = get-dnsserverresourcerecord -zonename "mikster22.co.uk" -rrtype "A" -node $newobj.recorddata.ipv4address=[System.Net.IPAddress]::parse($newip) Set-dnsserverresourcerecord -newinputobject $newobj -OldInputObject $oldobj -zonename "mikster22.co.uk" echo "mikster22.co.uk - A Records: updated" read-host
Here are the DNS Records:
Image may be NSFW.
Clik here to view.
As you can see, i have my (Local Server IP-Which i can't delete) Primary Nameserver and Secondary Nameserver. both of which also have a Web server.
When running my script-Yes i may want to update both, but i will probably run two separate scripts for this.
i want to know How to specify which record to update.
is there a way, of piping the output to a new variable, and telling this new variable to choose one the first / second line?
i also have a script which gets the secondary DNS server's IP
you may be wondering why i have specified two Web servers, this is because both servers are lowpowered, and based at home, with internet limits, power cuts, and obviously the need to turn of a server, my plan
is to get more Servers at Geographically wide locations and thus have a (low level) of redundancy.
Michael Booth