This discovery rule populates the DHCP 2012 Database installations.
DHCP Server 2012 Database Discovery get the DHCP 2012 Database objects, related properties and relationship.
These are the parameters that we could override, if need it:
Interval Seconds: Amount of Seconds for each execution
Sync Time: Time expressed with this format: "hh:mm" since you will like to start the execution.
Timeout Seconds: Amount of seconds to wait until cancel execution for "timeout reasons."
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>