Microsoft Windows Server DNS Forwarder Unconditional Discovery

Microsoft.Windows.Server.DNS.Forwarder.Unconditional.Discovery (Discovery)

Discovers Unconditional Forwarders

Knowledge Base article:

Summary

Uses WMI to discover unconditional forwarders.

Element properties:

TargetMicrosoft.Windows.Server.DNS.Server
EnabledTrue
Frequency14520
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Microsoft.Windows.Server.DNS.ActionAccount

Source Code:

<Discovery ID="Microsoft.Windows.Server.DNS.Forwarder.Unconditional.Discovery" Enabled="true" Target="Microsoft.Windows.Server.DNS.Server" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.Server.DNS.Forwarder.Unconditional">
<Property TypeID="Microsoft.Windows.Server.DNS.Forwarder" PropertyID="DomainName"/>
<Property TypeID="Microsoft.Windows.Server.DNS.Forwarder" PropertyID="IsConditional"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
<Property TypeID="Microsoft.Windows.Server.DNS.Forwarder" PropertyID="ForwarderTimeout"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.Server.DNS.Forwarder.IPAddress.Unconditional">
<Property TypeID="Microsoft.Windows.Server.DNS.Forwarder.IPAddress" PropertyID="IPAddress"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="Microsoft.Windows.Server.DNS.ActionAccount" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14520</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.Windows.Server.DNS.Forwarder.Unconditional.Discovery.vbs</ScriptName>
<Arguments/>
<ScriptBody><Script>'Copyright (c) Microsoft Corporation. All rights reserved.

'*************************************************************************
' ScriptName: Microsoft.Windows.Server.DNS.Forwarder.Unconditional.Discovery
'
' Purpose: DNS Forwarder Unconditional Discovery
'
' File: Microsoft.Windows.Server.DNS.Forwarder.Unconditional.Discovery.vbs
'*************************************************************************

Option Explicit

SetLocale("en-us")

Dim strSourceId, strManagedEntityId, strTargetComputer, wmiNamespaceString, wmiQueryString
Dim junkVar
Dim oAPI, oDiscoveryData, objWMIService, colitems, objItem, lInst,i,iInst

strSourceId = "$MPElement$"
strManagedEntityId = "$Target/Id$"
strTargetComputer = "$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$"
wmiNamespaceString = "winmgmts://./root/MicrosoftDNS"
wmiQueryString = "Select * from MicrosoftDNS_Server"

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, strSourceId, strManagedEntityId)

ON ERROR RESUME NEXT
set objWMIService = GetObject(wmiNamespaceString)

If Err.Number &lt;&gt; 0 Then
Call ReturnDiscovery
End If

set colitems = objWMIService.ExecQuery(wmiQueryString)
junkVar = colitems.count

If Err.Number &lt;&gt; 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$", "&lt;ALL&gt;")
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 " &amp; 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$", "&lt;ALL&gt;")
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>