Dim strSourceId, strManagedEntityId, strTargetComputer, wmiNamespaceString, wmiQueryString
Dim junkVar
Dim oAPI, oDiscoveryData, objWMIService, colitems, objItem, lInst,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.Forwarders) Then
Set lInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.Unconditional']$")
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$", "<ALL>")
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder']/IsConditional$", CBool("False"))
call lInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder']/ForwarderTimeout$", objItem.ForwardingTimeout)
call lInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Unconditional Forwarder on " & strTargetComputer)
Call oDiscoveryData.AddInstance(lInst)
For i = 0 to UBound(objItem.Forwarders)
Set iInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.IPAddress.Unconditional']$")
call iInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTargetComputer)
call iInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Server']/Name$", strTargetComputer)
call iInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder']/DomainName$", "<ALL>")
call iInst.AddProperty("$MPElement[Name='Microsoft.Windows.Server.DNS.Forwarder.IPAddress']/IPAddress$", objItem.Forwarders(i))
Call oDiscoveryData.AddInstance(iInst)
Next
End If
Next
Call ReturnDiscovery
Sub ReturnDiscovery
Call oAPI.Return(oDiscoveryData)
WScript.Quit
End Sub</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>