![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
programmatically change dns a record
i have a need (HA FAILOVER) to programmatically change a servers ip address
in it's a record. fields to be changed would be IPAddress RecordData TextRepresentation theoretically script would look like this ################### $changeip = Get-WmiObject -ComputerName DNSSERVER namespace "root\microsoftdns" -class MICROSOFTDNS_ATYPE | where {$_.Ownername -match "servername.domain"} $changeip.IPAddress = "xxx.xxx.xxx.xxx" $changeip.RecordData = "xxx.xxx.xxx.xxx" $changeip.TextRepresentation = "servername.domain IN A xxx.xxx.xxx.xxx" $changeip.put() ################### any reason that this should/shouldn't work ?? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: programmatically change dns a record
Hi voodooking,
It creates a new host record rather then updating it. Try to use the modify() method instead: $a = Get-WmiObject -ComputerName DNSSERVER -namespace "root\microsoftdns" -class MICROSOFTDNS_ATYPE -filter "OwnerName='shayTest.domain.com'" # Modify(System.UInt32 TTL, System.String IPAddress)} $a.modify($null,"xxx.xxx.xxx.xxx") Note that the query can return multiple host records, in that case use foreach. --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com v> i have a need (HA FAILOVER) to programmatically change a servers ip v> address v> in it's a record. v> fields to be changed would be v> IPAddress v> RecordData v> TextRepresentation v> theoretically script would look like this v> ################### v> $changeip = Get-WmiObject -ComputerName DNSSERVER namespace v> "root\microsoftdns" -class MICROSOFTDNS_ATYPE | where {$_.Ownername v> -match v> "servername.domain"} v> $changeip.IPAddress = "xxx.xxx.xxx.xxx" v> $changeip.RecordData = "xxx.xxx.xxx.xxx" v> $changeip.TextRepresentation = "servername.domain IN A v> xxx.xxx.xxx.xxx" v> $changeip.put() v> ################### v> any reason that this should/shouldn't work ?? |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|