Découverte de base de données DHCP 2016 et ultérieures

Microsoft.Windows.DHCPServer.10.0.Database.Discovery (Discovery)

Cette règle de découverte remplit les installations de base de données DHCP 2016 et ultérieures.

Knowledge Base article:

Résumé

La découverte de la base de données de serveur DHCP 2016 et versions ultérieures obtient les objets Base de données DHCP 2016 et versions ultérieures ainsi que les propriétés et la relation associées.

Voici les paramètres qui peuvent être remplacés si nécessaire :

Element properties:

TargetMicrosoft.Windows.DHCPServer.10.0.Server
EnabledTrue
Frequency86400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider System.PrivilegedMonitoringAccount

Source Code:

<Discovery ID="Microsoft.Windows.DHCPServer.10.0.Database.Discovery" Enabled="true" Target="Microsoft.Windows.DHCPServer.10.0.Server" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database">
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database" PropertyID="BackupInterval"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database" PropertyID="BackupPath"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database" PropertyID="CleanupInterval"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database" PropertyID="LoggingEnabled"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database" PropertyID="Path"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Database" PropertyID="RestoreFlag"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.DHCPComponent" PropertyID="Name"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="Name"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="System!System.PrivilegedMonitoringAccount" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverDHCPDatabase.10.0.ps1</ScriptName>
<ScriptBody><Script>

param ([String] $ElementID, [String] $TargetID, [String] $PrincipalName, [String] $NetbiosComputerName)
$SCRIPT_NAME = "DiscoverDHCPDatabase.10.0"
$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

$ComputerKey = "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$"
$ServerName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/Name$"
$ComponentName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.DHCPComponent']/Name$"
$DHCPType = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']$"
$Name = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/Name$"
$DisplayName = "$MPElement[Name='System!System.Entity']/DisplayName$"
$BackupInterval = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']/BackupInterval$"
$BackupPath = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']/BackupPath$"
$CleanupInterval = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']/CleanupInterval$"
$LoggingEnabled = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']/LoggingEnabled$"
$Path = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']/Path$"
$RestoreFlag = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Database']/RestoreFlag$"

Write-Host "$SCRIPT_NAME - Executing DHCP 2016 and 1709+ Database Discovery Powershell Script"

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

$DHCPDB = Get-DhcpServerDatabase

if ($DHCPDB -eq $null)
{
Write-Host "$SCRIPT_NAME - No DHCP 2016 and 1709+ Database installed on the Server"
$discoveryData
exit
}
else
{
$targeDHCPDB = $discoveryData.CreateClassInstance($DHCPType)
$targeDHCPDB.AddProperty($ComputerKey, $PrincipalName)
$targeDHCPDB.AddProperty($ServerName, $PrincipalName)
$targeDHCPDB.AddProperty($ComponentName, $PrincipalName + "-DHCP 2016 and 1709+ Database")
$targeDHCPDB.AddProperty($DisplayName, $PrincipalName + "-DHCP 2016 and 1709+ Database")
$targeDHCPDB.AddProperty($BackupInterval, $DHCPDB.BackupInterval)
$targeDHCPDB.AddProperty($BackupPath, $DHCPDB.BackupPath)
$targeDHCPDB.AddProperty($CleanupInterval, $DHCPDB.CleanupInterval)
$targeDHCPDB.AddProperty($Path, $DHCPDB.FileName)
$targeDHCPDB.AddProperty($RestoreFlag, $DHCPDB.RestoreFromBackup)

$discoveryData.AddInstance($targeDHCPDB)
Write-Host "$SCRIPT_NAME - DHCP 2016 and 1709+ Database 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>PrincipalName</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>NetbiosComputerName</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>