This discovery rule populates the DHCP 2012 Server instances.
DHCP Server 2012 Server Discovery get the DHCP 2012 Server object, 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.Server.6.2.Computer |
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.Server.Discovery" Enabled="true" Target="BaseOS!Microsoft.Windows.Server.6.2.Computer" ConfirmDelivery="true" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.DHCPServer.2012.Server">
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="Name"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="AdministrativeRights"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="AuditDiskCheckInterval"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="AuditMaxLogSize"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="AuditMinDiskSpace"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="BindingsAware"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="BootPEnabled"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="ConflictPingRetries"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="ADIntegrated"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="v4AuditEnabled"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="v4AuditFilePath"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="DNSDynamicUpdates"/>
<Property TypeID="DHCP!Microsoft.Windows.DHCPServer.Library.Server" PropertyID="OSCurrentVersion"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="NAPDefaultFail"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="NAPEnabled"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6AuditEnabled"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6AuditFilePath"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6BindingIsEnabledArray"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6PreferredIATALifetime"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6PreferredLifetime"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6RapidCommitFlag"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6T1"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6T2"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6UnicastFlag"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6ValidIATALifetime"/>
<Property TypeID="Microsoft.Windows.DHCPServer.2012.Server" PropertyID="v6ValidLifetime"/>
</DiscoveryClass>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="System!System.PrivilegedMonitoringAccount" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverDHCPServer2012</ScriptName>
<ScriptBody>
param ([String] $ElementID, [String] $TargetID, [String] $PrincipalName, [String] $NetbiosComputerName)
$SCRIPT_NAME = "DiscoverDHCPServer2012"
$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
$TargetOSVersion = "6.2"
$ComputerKey = "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$"
$DHCPType = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']$"
$Name = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/Name$"
$DisplayName = "$MPElement[Name='System!System.Entity']/DisplayName$"
$ADIntegrated = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/ADIntegrated$"
$BootPEnabled = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/BootPEnabled$"
$BindingsAware = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/BindingsAware$"
$AdmRights = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/AdministrativeRights$"
$AuditDiskCheckInterval = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/AuditDiskCheckInterval$"
$AuditMaxLogSize = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/AuditMaxLogSize$"
$AuditMinDiskSpace = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/AuditMinDiskSpace$"
$AuditEnabled = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/v4AuditEnabled$"
$AuditFilePath = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/v4AuditFilePath$"
$DNSDynamicUpdates = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/DNSDynamicUpdates$"
$ConflictPingRetries = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/ConflictPingRetries$"
$OSCurrentVersion = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/OSCurrentVersion$"
$NAPEnabled = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/NAPEnabled$"
$V6AuditEnabled = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6AuditEnabled$"
$V6AuditFilePath = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6AuditFilePath$"
$V6T1 = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6T1$"
$V6T2 = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6T2$"
$V6ValidLifeTime = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6ValidLifetime$"
$V6ValidIATALifeTime = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6ValidIATALifetime$"
$V6UnicastFlag = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6UnicastFlag$"
$v6RapidCommitFlag = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6RapidCommitFlag$"
$v6BindingIsEnabledArray = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.Server']/v6BindingIsEnabledArray$"
Write-Host "$SCRIPT_NAME - Executing DHCP Server Discovery Powershell Script"
$discoveryData = $momAPI.CreateDiscoveryData(0, $ElementID, $TargetID)
$OS = Get-ItemProperty "hklm:\software\microsoft\windows nt\currentversion"
if ($OS.CurrentVersion -ne $TargetOSVersion)
{
Write-Host "$SCRIPT_NAME - No Target Operating System"
$discoveryData
exit
}
else
{
$DHCP = Get-WindowsFeature DHCP
if ($DHCP.InstallState -eq $null)
{
Write-Host "$SCRIPT_NAME - No DHCP feature installed in the Server"
$discoveryData
exit
}
else
{
if ($DHCP.InstallState -eq "Installed")
{
$targetServer = $discoveryData.CreateClassInstance($DHCPType)
$targetServer.AddProperty($ComputerKey, $PrincipalName)
$targetServer.AddProperty($Name, $PrincipalName)
$targetServer.AddProperty($DisplayName, $PrincipalName)
$DHCPServer = Get-DhcpServerSetting
$targetServer.AddProperty($ADIntegrated, $DHCPServer.IsDomainJoined)
$targetServer.AddProperty($BootPEnabled, $DHCPServer.DynamicBootp)
$targetServer.AddProperty($ConflictPingRetries, $DHCPServer.ConflictDetectionAttempts)
$targetServer.AddProperty($NAPEnabled, $DHCPServer.NAPEnabled)
$targetServer.AddProperty($OSCurrentVersion, $OS.CurrentVersion)
$DHCPv4 = Get-DhcpServerv4Binding
$DHCPv6 = Get-DhcpServerv6Binding
if ($DHCPv4 -ne $null)
{
if($DHCPv4.BindingState.Count -gt 1)
{
$BindingEnabled = $DHCPv4.BindingState.GetValue(1)
}
else
{
$BindingEnabled = $DHCPv4.BindingState
}
}
else
{
if ($DHCPv6 -ne $null)
{
if($DHCPv6.BindingState.Count -gt 1)
{
$BindingEnabled = $DHCPv6.BindingState.GetValue(1)
}
else
{
$BindingEnabled = $DHCPv6.BindingState
}
}
else
{
$BindingEnabled = $false
}
$targetServer.AddProperty($v6BindingIsEnabledArray, $BindingEnabled)
}
$targetServer.AddProperty($BindingsAware, $BindingEnabled)
$targetServer.AddProperty($AdmRights, $true)
$DHCPAudit = Get-DhcpServerAuditLog
$targetServer.AddProperty($AuditDiskCheckInterval, $DHCPAudit.DiskCheckInterval)
$targetServer.AddProperty($AuditMaxLogSize, $DHCPAudit.MaxMBFileSize)
$targetServer.AddProperty($AuditMinDiskSpace, $DHCPAudit.MinMBDiskSpace)
$targetServer.AddProperty($AuditEnabled, $DHCPAudit.Enable)
$targetServer.AddProperty($AuditFilePath, $DHCPAudit.Path)
$IPV4DNS = Get-DhcpServerv4DnsSetting
if ( $IPV4DNS.DynamicUpdates -eq "OnClientRequest")
{
$targetServer.AddProperty($DNSDynamicUpdates, 1)
}
else
{
$targetServer.AddProperty($DNSDynamicUpdates, 0)
}
$T6S = Get-DhcpServerv6Scope
if ($T6S.T1 -ne $null)
{
if($T6S.T1.TotalHours.Count -ge 1)
{
$TotHrs01 = $T6S.T1.TotalHours.Item(0).toString()
}
else
{
$TotHrs01 = $T6S.T1.TotalHours
}
$targetServer.AddProperty($V6T1, $TotHrs01)
}
if ($T6S.T2 -ne $null)
{
if($T6S.T2.TotalHours.Count -ge 1)
{
$TotHrs02 = $T6S.T2.TotalHours.Item(0).toString()
}
else
{
$TotHrs02 = $T6S.T2.TotalHours
}
$targetServer.AddProperty($V6T2, $TotHrs02)
}
$targetServer.AddProperty($V6AuditEnabled, $DHCPAudit.Enable)
$targetServer.AddProperty($V6AuditFilePath, $DHCPAudit.Path)
if ($T6S.ValidLifetime -ne $null)
{
if($T6S.ValidLifetime.Count -ge 1)
{
$TotHrs03 = $T6S.ValidLifetime.TotalHours.Item(0).toString()
}
else
{
$TotHrs03 = $T6S.ValidLifetime.TotalHours.Item(0).toString()
}
$targetServer.AddProperty($V6ValidLifeTime, $TotHrs03)
$targetServer.AddProperty($V6ValidIATALifeTime, $TotHrs03)
}
$targetServer.AddProperty($V6UnicastFlag, $false)
$targetServer.AddProperty($v6RapidCommitFlag, $false)
$discoveryData.AddInstance($targetServer)
$discoveryData
Write-Host "$SCRIPT_NAME - Discovery data returned"
}
else
{
Write-Host "$SCRIPT_NAME - No DHCP feature installed in the Server"
$discoveryData
exit
}
}
}
</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/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>NetbiosComputerName</Name>
<Value>$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>