Using WMI it is possible to modify any existing record hosted on a Microsoft DNS Server. The method used varies slightly depending on which record type we want to change.

References for each version of the Modify method can be found in the DNS WMI Provider Reference. These are the most common:

The examples below show modification of Host or A records, but it is possible to extend the example to use any of the types above.

Using VbScript to modify records

This example demonstrates the use of WMI in VbScript to modify a record. The first value for Modify is the TTL, by using objItem.TTL we just reinsert the existing value, only changing the IP address.

If the TTL must be changed it is important to exclude the IP Address parameter, failure to do so will result in the record being deleted. Any attempt to use Modify without making any changes will result in a “SWbemObjectEx: Generic failure” exception.

Using PowerShell to modify records

The same failure reasons and restrictions apply with PowerShell (including the obscure deletion). Otherwise changing the record can be performed like this.

In both VbScript and PowerShell the method call returns an object representing the updated record if further processing is required.


  1. With WS2003 DNS Servers at least, it appears using the Modify method to change only the TTL results in the Timestamp being dropped from the record, making it static.


  2. Justin McAlister

    Hi Chris,

    It seems like the modify method sets the timestamp to static regardless of what is passed for the TTL argument. Do you know of any ways to keep the timestamp value intact?

    Thank you,



  3. Pingback: Modifying DNS records with WMI | Indented! | Cuvages Sistemas

Leave a Reply

Your email address will not be published. Required fields are marked *