Cette règle de détection remplit les instances de la base de données DHCP 2012.
La détection de base de données DHCP 2012 obtient les objets, les propriétés associées et la relation de la base de données DHCP 2012.
Voici les paramètres que nous pourrions remplacer, si nécessaire :
Intervalle en secondes : Nombre de secondes pour chaque exécution
Heure de synchronisation : Heure exprimée sous le format suivant : « hh:mm » depuis le début de l'exécution désirée.
Délai d'attente (secondes) : Nombre de secondes avant l'annulation de l'exécution en raison de l'expiration du délai d'attente.
Target | Microsoft.Windows.DHCPServer.2012.Server |
Enabled | True |
Frequency | 86400 |
Remotable | False |
Discovered Classes and their attribuets: |
---|
|
ID | Module Type | TypeId | RunAs |
---|---|---|---|
DS | DataSource | Microsoft.Windows.TimedPowerShell.DiscoveryProvider | System.PrivilegedMonitoringAccount |
<Discovery ID="Microsoft.Windows.DHCPServer.2012.Database.Discovery" Enabled="true" Target="Microsoft.Windows.DHCPServer.2012.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>DiscoverDHCPDatabase2012</ScriptName>
<ScriptBody>
param ([String] $ElementID, [String] $TargetID, [String] $PrincipalName, [String] $NetbiosComputerName)
$SCRIPT_NAME = "DiscoverDHCPDatabase2012"
$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 2012 Database Discovery Powershell Script"
$discoveryData = $momAPI.CreateDiscoveryData(0, $ElementID, $TargetID)
$DHCPDB = Get-DhcpServerDatabase
if ($DHCPDB -eq $null)
{
Write-Host "$SCRIPT_NAME - No DHCP 2012 Databse installed in the Server 2012"
$discoveryData
exit
}
else
{
$targeDHCPDB = $discoveryData.CreateClassInstance($DHCPType)
$targeDHCPDB.AddProperty($ComputerKey, $PrincipalName)
$targeDHCPDB.AddProperty($ServerName, $PrincipalName)
$targeDHCPDB.AddProperty($ComponentName, $PrincipalName + "-DHCP 2012 Database")
$targeDHCPDB.AddProperty($DisplayName, $PrincipalName + "-DHCP 2012 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 2012 Database Added to Discovery data"
$discoveryData
Write-Host "$SCRIPT_NAME - Discovery data returned"
}
</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>