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 ??