Découverte du point d'approbation dans le DNS Windows Server 2012 R2

Microsoft.Windows.Server.DNS.TrustPoint.Discovery (Discovery)

Ce workflow détecte tous les points d'approbation dans le DNS de tous les serveurs Windows 2012 R2

Knowledge Base article:

Résumé

Remplit les points d'approbation dans le DNS défini dans un ordinateur Windows Server 2012 R2.

Element properties:

TargetMicrosoft.Windows.Server.DNS.Server
EnabledFalse
Frequency15000
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

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

Source Code:

<Discovery ID="Microsoft.Windows.Server.DNS.TrustPoint.Discovery" Enabled="false" Target="Microsoft.Windows.Server.DNS.Server" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.Server.DNS.TrustPoint">
<Property TypeID="Microsoft.Windows.Server.DNS.TrustPoint" PropertyID="TrustPointName"/>
<Property TypeID="Microsoft.Windows.Server.DNS.TrustPoint" PropertyID="HostName"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="Microsoft.Windows.Server.DNS.ActionAccount" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>15000</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverDNSTrustPoint2012R2</ScriptName>
<ScriptBody><Script>

param ([String] $ElementID, [String] $TargetID, [String] $ServerName)

$SCRIPT_NAME = "DiscoverDNSTrustPoint2012R2"

$ErrorActionPreference = "Stop"

# Event type constants
$EVENT_TYPE_LOG = 0
$EVENT_TYPE_ERROR = 1
$EVENT_TYPE_WARNING = 2
$EVENT_TYPE_INFORMATION = 4

# Typed property bag constants
$PROPERTY_TYPE_ALERT = 0
$PROPERTY_TYPE_EVENT = 1
$PROPERTY_TYPE_PERFORMANCE = 2
$PROPERTY_TYPE_STATE = 3

# State type constants
$STATE_SUCCESS = "Success"
$STATE_WARNING = "Warning"
$STATE_ERROR = "Error"

$momAPI = new-object -comObject MOM.ScriptAPI


$TrustPointType = "$MPElement[Name='Microsoft.Windows.Server.DNS.TrustPoint']$"
$CompNameProp = "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$"
$DNSNameProp = "$MPElement[Name='Microsoft.Windows.Server.DNS.Server']/Name$"
$EntityDNProp = "$MPElement[Name='System!System.Entity']/DisplayName$"
$TPNameProp = "$MPElement[Name='Microsoft.Windows.Server.DNS.TrustPoint']/TrustPointName$"
$HostNameProp = "$MPElement[Name='Microsoft.Windows.Server.DNS.TrustPoint']/HostName$"


Write-Host "$SCRIPT_NAME - Executing DNS 2012 Trusted Points Discovery Powershell Script"

$discoveryData = $momAPI.CreateDiscoveryData(0, $ElementID, $TargetID)
$discoveryData.IsSnapshot = $true

$DNSTrustPoints = Get-DnsServerTrustPoint -ComputerName $ServerName

if($DNSTrustPoints -ne $null)
{
if($DNSTrustPoints.Count -eq $null)
{
$TPCount = 1
}
else
{
$TPCount = $DNSTrustPoints.Count
}

for ($itmTP=0; $itmTP -lt $TPCount; $itmTP++)
{
if($TPCount -eq 1)
{
$TPObj = $DNSTrustPoints
}
else
{
$TPObj = $DNSTrustPoints.Item($itmTP)
}

$TPState = $TPObj.TrustPointState

$TrustedPoint = $discoveryData.CreateClassInstance($TrustPointType)
$TrustedPoint.AddProperty($CompNameProp, $ServerName)
$TrustedPoint.AddProperty($DNSNameProp, $ServerName)
$TrustedPoint.AddProperty($TPNameProp, $TPObj.TrustPointName)
$TrustedPoint.AddProperty($HostNameProp, $ServerName)
$TrustedPoint.AddProperty($EntityDNProp, $TPObj.TrustPointName + " on " + $ServerName)

$discoveryData.AddInstance($TrustedPoint)

Write-Host "$SCRIPT_NAME - DNS 2012 R2 Trusted Point Added to Discovery data"

}

}

$discoveryData

Write-Host "$SCRIPT_NAME - Discovery data returned"</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>ElementID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>TargetID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>ServerName</Name>
<Value>$Target/Host/Property[Type='Windows!Microsoft.Windows.Computer']/PrincipalName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>