If (oReg.GetDWordValue(&H80000002, "SYSTEM\CurrentControlSet\Services\DNS\Parameters", "EnableGlobalNamesSupport", regVal) <> 0) Then
boolIsActivated = CBool("False")
Else
If CInt(regVal) = 1 Then
boolIsActivated = CBool("True")
Else
boolIsActivated = CBool("False")
End If
End If
If (oReg.GetDWordValue(&H80000002, "SYSTEM\CurrentControlSet\Services\DNS\Parameters", "GlobalNamesQueryOrder", regVal) <> 0) Then
strQueryOrder = "Local Zone First"
Else
If CInt(regVal) = 1 Then
strQueryOrder = "Local Zone First"
Else
strQueryOrder = "Global Zone First"
End If
End If
' Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']$")
' call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/IsActivated$", boolIsActivated)
' call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/QueryOrder$", strQueryOrder)
If InStr(strServerVersion, "10.") = 1 Then
Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']$")
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/IsActivated$", boolIsActivated)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/QueryOrder$", strQueryOrder)
Else
'Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']$")
'call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/IsActivated$", boolIsActivated)
'call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone.Global']/QueryOrder$", strQueryOrder)
End If
Else
' Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']$")
If InStr(strServerVersion, "10.") = 1 Then
Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']$")
'Else
'Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']$")
End If
End If
select case cint(objItem.ZoneType)
case 1
zoneTypeString="Primary"
case 2
zoneTypeString="Secondary"
case 3
zoneTypeString="Stub"
case Else
zoneTypeString="Unknown"
end select
select case cint(objItem.AllowUpdate)
case 0
dynamicType="None"
case 1
dynamicType="Secure and NonSecure"
case 2
dynamicType="Secure Only"
case Else
dynamicType="Other"
end select
strDataFile = "null"
If not IsNull(objItem.DataFile) Then
strDataFile = objItem.DataFile
End If
If Not IsNull(objItem.MasterServers) Then
strMS=""
For ix = 0 To UBound(objItem.MasterServers)
strMS=strMS & objItem.MasterServers(ix) & " "
Next
End If
Set colSOA = objWMIService.ExecQuery("Select * from MicrosoftDNS_SOAType Where ContainerName = '" & objItem.Name & "'")
For Each objSOA In colSOA
If Right(objSOA.PrimaryServer,1) = "." Then
strSOA = Left(objSOA.PrimaryServer,Len(objSOA.PrimaryServer)-1)
Else
strSOA = objSOA.PrimaryServer
End If
exit for
Next
nameServers=""
Set colZones2 = objWMIService.ExecQuery("Select nshost from MicrosoftDNS_nstype Where ContainerName = '" & objItem.containername & "'" & " and domainname='" & objItem.Name & "'" & " and dnsservername='" & objItem.dnsservername & "'" )
nameServers = GetNameServers(colZones2)
If InStr(strServerVersion, "10.") = 1 Then
call lInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTargetComputer)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Server']/Name$", strTargetComputer)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/ZoneName$", objItem.Name)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/ZoneType$", zoneTypeString)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/IsReverseZone$", CBool(objItem.Reverse))
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/IsADIntegrated$", CBool(objItem.DSIntegrated))
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/AllowDynamicUpdates$", dynamicType)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/AllowZoneTransfers$", CInt(objItem.SecureSecondaries))
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/PrimaryServerName$", strSOA)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/ZoneFileName$", strDataFile)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/UseWINS$", CBool(objItem.UseWins))
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/HostName$", strTargetComputer)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/NameServers$", nameServers)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.DNSServer.2016.Zone']/MasterServers$", strMS)
call lInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Zone " & objItem.Name & " on " & strTargetComputer)
Call oDiscoveryData.AddInstance(lInst)
'Else
'call lInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Zone " & objItem.Name & " on " & strTargetComputer)
End If
End If
Next
Call ReturnDiscovery
Sub ReturnDiscovery
Call oAPI.Return(oDiscoveryData)
WScript.Quit
End Sub
Function GetNameServers(ZonesColl)
Dim DataList, objTmpZone
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "nshost", 200, 255
DataList.Open
For Each objTmpZone In ZonesColl
DataList.AddNew
DataList("nshost") = objTmpZone.nshost
DataList.Update
Next
DataList.Sort = "nshost"
If DataList.EOF Then
GetNameServers = ""
Exit Function
End If
DataList.MoveFirst
Do Until DataList.EOF
nameServers=nameServers & DataList.Fields.Item("nshost") & " "
DataList.MoveNext
Loop
DataList.Close
Set DataList = Nothing
GetNameServers = nameServers
End Function</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>