This datasource discovers DHCP 2012 Scopes using paging for large quantities.
This data source module discoveres Scopes using the given paging parameters in Windows Server 2012 that got the DHCP feature enabled.
Interval Seconds: How frequently (in seconds) the value should be checked.
Sync Time: Synchronization time for the module execution.
Timeout Seconds: How much time (in seconds) to wait for the module to finish execution.
Initial Row: How much time (in seconds) to wait for the module to finish execution.
Final Row: How much time (in seconds) to wait for the module to finish execution.
Type | DataSourceModuleType |
Isolation | Any |
Accessibility | Public |
RunAs | Default |
OutputType | System.Discovery.Data |
ID | Module Type | TypeId | RunAs |
---|---|---|---|
DS1 | DataSource | System.Discovery.Scheduler | Default |
PS2 | ProbeAction | Microsoft.Windows.PowerShellDiscoveryProbe | Default |
ID | ParameterType | Selector | Display Name | Description |
---|---|---|---|---|
InitialRow | int | $Config/InitialRow$ | Initial Row | This is the initial row to return in the discovery. |
FinalRow | int | $Config/FinalRow$ | Final Row | This is the final row to return in the discovery. |
IntervalSeconds | int | $Config/IntervalSeconds$ | Interval seconds | How frequently (in seconds) the value should be sampled. |
SyncTime | string | $Config/SyncTime$ | Sync Time | Synchronization time for the module execution. |
TimeoutSeconds | int | $Config/TimeoutSeconds$ | Timeout Seconds | Expecting time (in seconds) that the module wait to finish the execution. |
<DataSourceModuleType ID="Microsoft.Windows.DHCPServer.2012.Scopes.Paging.DiscoveryProvider" Accessibility="Public">
<Configuration>
<xsd:element minOccurs="1" name="PrincipalName" type="xsd:string"/>
<xsd:element minOccurs="1" name="NetbiosComputerName" type="xsd:string"/>
<xsd:element minOccurs="1" name="InitialRow" type="xsd:integer"/>
<xsd:element minOccurs="1" name="FinalRow" type="xsd:integer"/>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" name="SyncTime" type="xsd:string"/>
<xsd:element minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="InitialRow" Selector="$Config/InitialRow$" ParameterType="int"/>
<OverrideableParameter ID="FinalRow" Selector="$Config/FinalRow$" ParameterType="int"/>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource TypeID="System!System.Discovery.Scheduler" ID="DS1">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/SyncTime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe" ID="PS2">
<ScriptName>DiscoverDHCPScopes2012WithPaging</ScriptName>
<ScriptBody>
param ([String] $ElementID, [String] $TargetID, [String] $PrincipalName, [String] $NetbiosComputerName, [Int] $InitialRow, [Int] $FinalRow)
$SCRIPT_NAME = "DiscoverDHCPScope2012"
$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$"
$DisplayName = "$MPElement[Name='System!System.Entity']/DisplayName$"
$ServerName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/Name$"
$ComponentName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.DHCPComponent']/Name$"
$DHCPType03 = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.IPv4Runtime']$"
$Name = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Server']/Name$"
$IPAddress = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Scope']/IPAddress$"
$SubnetMask = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Scope']/SubnetMask$"
$IsEnabled = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Scope']/IsEnabled$"
$OSCurrentVersion = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Scope']/OSCurrentVersion$"
$ScopeName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Scope']/Name$"
$DHCPType01 = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.IPv4Scope']$"
$DHCPType02 = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.IPv6Scope']$"
$DHCPType04 = "$MPElement[Name='Microsoft.Windows.DHCPServer.2012.IPv6Runtime']$"
$DHCPType05 = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Superscope']$"
$PrincNameProp = "$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$"
$SuperScopeName = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Superscope']/Name$"
$SuperOSCurrVer = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Superscope']/OSCurrentVersion$"
$SuperScopeRel = "$MPElement[Name='DHCP!Microsoft.Windows.DHCPServer.Library.Contains.SuperscopeContainsScope']$"
Write-Host "$SCRIPT_NAME - Executing DHCP Scope Discovery Powershell Script"
$discoveryData = $momAPI.CreateDiscoveryData(0, $ElementID, $TargetID)
$OS = Get-ItemProperty "hklm:\software\microsoft\windows nt\currentversion"
$IPV4Scopes = Get-DhcpServerv4Scope
$IPV6Scopes = Get-DhcpServerv6Scope
if($IPV4Scopes -eq $null)
{
$IPV4ScopesCount = 0
}
else
{
if($IPV4Scopes.Count -eq $null)
{
$IPV4ScopesCount = 1
}
else
{
$IPV4ScopesCount = $IPV4Scopes.Count
}
}
if($IPV6Scopes -eq $null)
{
$IPV6ScopesCount = 0
}
else
{
if($IPV6Scopes.Count -eq $null)
{
$IPV6ScopesCount = 1
}
else
{
$IPV6ScopesCount = $IPV6Scopes.Count
}
}
if ($IPV4ScopesCount -eq 0 -and $IPV6ScopesCount -eq 0)
{
Write-Host "$SCRIPT_NAME - No DHCP Scopes installed in the Server"
$discoveryData
exit
}
else
{
$ArrSuperScopeObjts = @()
$ArrSuperScopeNames = @()
if ($IPV4ScopesCount -gt 0)
{
$targetIPV4Runtime = $discoveryData.CreateClassInstance($DHCPType03)
$targetIPV4Runtime.AddProperty($ComputerKey, $PrincipalName)
$targetIPV4Runtime.AddProperty($ServerName, $PrincipalName)
$targetIPV4Runtime.AddProperty($ComponentName, $PrincipalName + "-IPv4 Runtime")
$targetIPV4Runtime.AddProperty($DisplayName, "IPv4 Runtime" + " (" + $PrincipalName + ")")
$discoveryData.AddInstance($targetIPV4Runtime)
$SuperScopes = Get-DHCPServerv4Superscope
if($SuperScopes.Length -eq $null)
{
$SuperScopeCount = 1
}
else
{
$SuperScopeCount = $SuperScopes.Length
}
for ($itmSupScp=0; $itmSupScp -lt $SuperScopeCount; $itmSupScp++)
{
if($SuperScopes.Length -eq $null)
{
$ObjSuperScope = $SuperScopes
}
else
{
if($SuperScopes.Get($itmSupScp) -ne $null)
{
$ObjSuperScope = $SuperScopes.Get($itmSupScp)
}
}
if($ObjSuperScope.SuperscopeName.Length -gt 0)
{
$targetSuperScope = $discoveryData.CreateClassInstance($DHCPType05)
$targetSuperScope.AddProperty($PrincNameProp, $PrincipalName)
$targetSuperScope.AddProperty($ServerName, $PrincipalName)
$targetSuperScope.AddProperty($SuperScopeName, $ObjSuperScope.SuperscopeName)
$targetSuperScope.AddProperty($DisplayName, $ObjSuperScope.SuperscopeName + " (" + $PrincipalName + ")" )
$targetSuperScope.AddProperty($SuperOSCurrVer, $OS.CurrentVersion)
$ArrSuperScopeObjts += @($targetSuperScope)
$ArrSuperScopeNames += @($ObjSuperScope.SuperscopeName)
$discoveryData.AddInstance($targetSuperScope)
Write-Host "$SCRIPT_NAME - SuperScope Added to Discovery data"
}
}
#New Scopes discovery
$IPV4Initial = if($InitialRow -eq 0){1}else{$InitialRow}
$IPV4Count = if($FinalRow -eq 0){$IPV4ScopesCount}else{$FinalRow}
for ($itmIPV4Scope=$IPV4Initial; $itmIPV4Scope -le $IPV4Count; $itmIPV4Scope++)
{
if($itmIPV4Scope -ge $IPV4Initial -and $itmIPV4Scope -le $IPV4Count)
{
if($IPV4ScopesCount -eq 1)
{
$ObjIPV4Scope = $IPV4Scopes
}
else
{
if($IPV4Scopes.Get($itmIPV4Scope-1) -ne $null)
{
$ObjIPV4Scope = $IPV4Scopes.Get($itmIPV4Scope-1)
}
}
$targetIPV4Scope = $discoveryData.CreateClassInstance($DHCPType01)
$targetIPV4Scope.AddProperty($ComputerKey, $PrincipalName)
$targetIPV4Scope.AddProperty($ServerName, $PrincipalName)
$targetIPV4Scope.AddProperty($ComponentName, $PrincipalName + " - " + $ObjIPV4Scope.Name)
$targetIPV4Scope.AddProperty($DisplayName, $PrincipalName + " - " + $ObjIPV4Scope.Name)
$targetIPV4Scope.AddProperty($IPAddress, $ObjIPV4Scope.ScopeId.toString())
$targetIPV4Scope.AddProperty($SubnetMask, $ObjIPV4Scope.SubnetMask.toString())
if($ObjIPV4Scope.State -eq "Active")
{
$targetIPV4Scope.AddProperty($IsEnabled, $true)
}
else
{
$targetIPV4Scope.AddProperty($IsEnabled, $false)
}
$targetIPV4Scope.AddProperty($OSCurrentVersion, $OS.CurrentVersion)
$targetIPV4Scope.AddProperty($ScopeName, $ObjIPV4Scope.Name)
$discoveryData.AddInstance($targetIPV4Scope)
Write-Host "$SCRIPT_NAME - IPV4 Added to Discovery data"
$IndScope = $ArrSuperScopeNames.IndexOf($ObjIPV4Scope.SuperscopeName)
if($IndScope -ne -1)
{
$objSupScope = $ArrSuperScopeObjts[$IndScope]
$oRelationship = $discoveryData.CreateRelationshipInstance($SuperScopeRel)
$oRelationship.Source = $objSupScope
$oRelationship.Target = $targetIPV4Scope
$discoveryData.AddInstance($oRelationship)
Write-Host "$SCRIPT_NAME - SuperScope Relationship Added to Discovery data"
}
}
}
}
if ($IPV6ScopesCount -gt 0)
{
$targetIPV6Runtime = $discoveryData.CreateClassInstance($DHCPType04)
$targetIPV6Runtime.AddProperty($ComputerKey, $PrincipalName)
$targetIPV6Runtime.AddProperty($ServerName, $PrincipalName)
$targetIPV6Runtime.AddProperty($ComponentName, $PrincipalName + "-IPv6 Runtime")
$targetIPV6Runtime.AddProperty($DisplayName, "IPv6 Runtime" + " (" + $PrincipalName + ")")
$discoveryData.AddInstance($targetIPV6Runtime)
#New Scopes discovery
$IPV6Initial = if($InitialRow -eq 0){1}else{$InitialRow}
$IPV6Count = if($FinalRow -eq 0){$IPV6ScopesCount}else{$FinalRow}
for ($itmIPV6Scope=$IPV6Initial; $itmIPV6Scope -le $IPV6Count; $itmIPV6Scope++)
{
if($itmIPV6Scope -ge $IPV6Initial -and $itmIPV6Scope -le $IPV6Count)
{
if($IPV6ScopesCount -eq 1)
{
$ObjIPV6Scope = $IPV6Scopes
}
else
{
if($IPV6Scopes.Get($itmIPV6Scope-1) -ne $null)
{
$ObjIPV6Scope = $IPV6Scopes.Get($itmIPV6Scope-1)
}
}
$targetIPV6Scope = $discoveryData.CreateClassInstance($DHCPType02)
$targetIPV6Scope.AddProperty($ComputerKey, $PrincipalName)
$targetIPV6Scope.AddProperty($ServerName, $PrincipalName)
$targetIPV6Scope.AddProperty($ComponentName, $PrincipalName + " - " + $ObjIPV6Scope.Name)
$targetIPV6Scope.AddProperty($DisplayName, $PrincipalName + " - " + $ObjIPV6Scope.Name)
$targetIPV6Scope.AddProperty($IPAddress, $ObjIPV6Scope.Prefix.toString())
$targetIPV6Scope.AddProperty($SubnetMask, "")
if($ObjIPV6Scope.State -eq "Active")
{
$targetIPV6Scope.AddProperty($IsEnabled, $true)
}
else
{
$targetIPV6Scope.AddProperty($IsEnabled, $false)
}
$targetIPV6Scope.AddProperty($OSCurrentVersion, $OS.CurrentVersion)
$targetIPV6Scope.AddProperty($ScopeName, $ObjIPV6Scope.Name)
$discoveryData.AddInstance($targetIPV6Scope)
Write-Host "$SCRIPT_NAME - IPV6 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>$Config/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>NetbiosComputerName</Name>
<Value>$Config/NetbiosComputerName$</Value>
</Parameter>
<Parameter>
<Name>InitialRow</Name>
<Value>$Config/InitialRow$</Value>
</Parameter>
<Parameter>
<Name>FinalRow</Name>
<Value>$Config/FinalRow$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PS2">
<Node ID="DS1"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>