tags:

views:

383

answers:

1

Hi,

Has anyone used the WMI ChangeZoneType DNS command in C#\VB.net before. I get an incorrect parameter exception when i try and invoke the changezonetype command. I get the dns zone that i want to change from the dns server (via query), set the zonetype to the appropriate uint value but am then getting the exception. I am trying to change the zone from secondary to primary and according to MSDN all the other values are optional (and as far as i am aware are needed when you want to change from primary to secondary) so i have not included them.

Below is the code that i am using....

        For Each DNSZone As ManagementObject In mgrZones
            mngrZones = DNSZone.GetMethodParameters("ChangeZoneType")
            mngrZones("ZoneType") = System.Convert.ToUInt32(zoneType)
            DNSZone.InvokeMethod("ChangeZoneType", mngrZones, Nothing)
        Next

Anyone got any ideas?

Thanks

A: 

Hi,

After looking around for some answers i tried the following and it worked.

enter code here
    For Each DNSZone As ManagementObject In mgrZones            
         DNSZone("zonetype") = 1 'sets it to primary
         DNSZone.Put()
   Next

Niall

Niall