Dim strSourceId, strManagedEntityId, strTargetComputer, wmiNamespaceString, wmiQueryString
Dim junkVar
Dim oAPI, oDiscoveryData, objWMIService, colitems, objItem, lInst
Dim i, iInst
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, strSourceId, strManagedEntityId)
ON ERROR RESUME NEXT
set objWMIService = GetObject(wmiNamespaceString)
If Err.Number <> 0 Then
Call ReturnDiscovery
End If
set colitems = objWMIService.ExecQuery(wmiQueryString)
junkVar = colitems.count
If Err.Number <> 0 Then
Call ReturnDiscovery
End If
If ( colitems.count = 0 ) Then
Call ReturnDiscovery
End If
For Each objItem In colitems
If Not IsNull(objItem.Name) Then
If LCase(Right(objItem.Name, 13)) = ".in-addr.arpa" Then
Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.Conditional.Reverse']$")
Else
Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.Conditional.Forward']$")
End If
call lInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTargetComputer)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Server']/Name$", strTargetComputer)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder']/DomainName$", objItem.Name)
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder']/IsConditional$", CBool("True"))
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder']/ForwarderTimeout$", objItem.ForwarderTimeout)
call lInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", objItem.Name & " on " & strTargetComputer)
Call oDiscoveryData.AddInstance(lInst)
For i = 0 to UBound(objItem.MasterServers)
If LCase(Right(objItem.Name, 13)) = ".in-addr.arpa" Then
Set iInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.IPAddress.Conditional.Reverse']$")
Else
Set iInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.IPAddress.Conditional.Forward']$")
End If