Windows Network Adapter Discovery

Microsoft.Windows.Server.10.0.NetworkAdapterDiscovery.ModuleType (DataSourceModuleType)

This rule discovers network adapters.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
Scheduler DataSource System.Discovery.Scheduler Default
ScriptProbe ProbeAction Microsoft.Windows.PowerShellDiscoveryProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval Seconds
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds
DiscoverDisabledNetworkAdaptersbool$Config/DiscoverDisabledNetworkAdapters$Discover Disabled Network Adapters

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.Server.10.0.NetworkAdapterDiscovery.ModuleType" Accessibility="Internal">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DiscoverDisabledNetworkAdapters" type="xsd:boolean"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="UseMacAddress" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
<OverrideableParameter ID="DiscoverDisabledNetworkAdapters" ParameterType="bool" Selector="$Config/DiscoverDisabledNetworkAdapters$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="ScriptProbe" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>Microsoft.Windows.Server.10.0.NetworkAdapterDiscovery.ModuleType.ps1</ScriptName>
<ScriptBody><Script>

param ($SourceID, $ManagedEntityId, $TargetComputer, $TargetComputerID, $IsDiscoverDisabled, $IsUseMacAddress)
$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
Import-Module CimCmdlets # Workaround to force load CIM cmdlets

# WMI Constant
$wbemCimtypeUseDefault = 0 #Use Default Type CIM type - Custom
$wbemCimtypeSint16 = 2 #Signed 16-bit integer
$wbemCimtypeSint32 = 3 #Signed 32-bit integer
$wbemCimtypeReal32 = 4 #32-bit real number
$wbemCimtypeReal64 = 5 #64-bit real number
$wbemCimtypeString = 8 #String
$wbemCimtypeBoolean = 11 #Boolean value
$wbemCimtypeObject = 13 #CIM object
$wbemCimtypeSint8 = 16 #Signed 8-bit integer
$wbemCimtypeUint8 = 17 #Unsigned 8-bit integer
$wbemCimtypeUint16 = 18 #Unsigned 16-bit integer
$wbemCimtypeUint32 = 19 #Unsigned 32-bit integer
$wbemCimtypeSint64 = 20 #Signed 64-bit integer
$wbemCimtypeUint64 = 21 #Unsigned 64-bit integer
$wbemCimtypeDatetime = 101 #Date/time value
$wbemCimtypeReference = 102 #Reference to a CIM object
$wbemCimtypeChar16 = 103 #16-bit character

$ErrAction_None = 0
$ErrAction_Trace = 1
$ErrAction_ThrowError = 16
$ErrAction_Abort = 32
$ErrAction_ThrowErrorAndAbort = 48

$DISKSIZE_BYTES_IN_MB = 1048576

$g_ErrorEventNumber = 4001
$g_TraceEventNumber = 4002
$g_DebugFlag = $false

#---------------------------------------------------------------------------
# Returns WMI Instance requested. Tries to execute WMI query a N times.
#---------------------------------------------------------------------------
Function WMIGetInstanceExTryN
{
param ([string]$sTargetComputer,
[string]$sNamespace,
[string]$sInstanceQuery,
[int]$N)

for ($i = 0; $i -lt $N; $i++)
{
$error.Clear();
$oInstance = Get-CimInstance -ComputerName $sTargetComputer -Namespace $sNamespace -Query ("Select * from "+$sInstanceQuery) -ErrorAction SilentlyContinue
if ($error.Count -gt 0)
{
if ($i -eq ($N-1))
{
ThrowScriptError ("The class name '" + $sInstanceQuery + "' returned no instances. Please check to see if this is a valid WMI class name.") $error[0]
}
}
else
{
break;
}
sleep -m 1000
}

return $oInstance
}

#---------------------------------------------------------------------------
# Returns WMI Instance requested.
#---------------------------------------------------------------------------
Function WMIGetInstanceEx
{
param ([string]$sTargetComputer,
[string]$sNamespace,
[string]$sInstanceQuery)

$error.Clear();
$oInstance = Get-CimInstance -ComputerName $sTargetComputer -Namespace $sNamespace -Query ("Select * from "+$sInstanceQuery) -ErrorAction SilentlyContinue
if ($error.Count -gt 0)
{
ThrowScriptError ("The class name '" + $sInstanceQuery + "' returned no instances. Please check to see if this is a valid WMI class name.") $error[0]
}

return $oInstance
}

#---------------------------------------------------------------------------
# Connect to WMI.
#---------------------------------------------------------------------------
Function WMIConnect
{
param ([string]$sTargetComputer,
[string]$sNamespace)

$error.Clear()

# !!! Refactoring comment:
# Original VBScript only tries to connect to the namespace. Piping to get only the first one saves time.
$oWMI = Get-CimClass -ComputerName $sTargetComputer -Namespace $sNamespace -ErrorAction SilentlyContinue | select -First 1
if ($error.Count -gt 0)
{
$msg = "Unable to open WMI Namespace 'winmgmts:\\" + $sTargetComputer + "\" + $sNamespace + "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists."
ThrowScriptError $msg $error[0]
}
}

#---------------------------------------------------------------------------
# Returns WMI Instance requested.
#---------------------------------------------------------------------------
Function WMIGetInstance
{
param ([string]$sTargetComputer,
[string]$sNamespace,
[string]$sInstanceQuery)

WMIConnect $sTargetComputer $sNamespace
$oInstance = WMIGetInstanceEx $sTargetComputer $sNamespace $sInstanceQuery
return $oInstance
}

#---------------------------------------------------------------------------
# Returns WMI Instance requested.
#---------------------------------------------------------------------------
Function WMIGetInstanceNoAbort
{
param ([string]$sTargetComputer,
[string]$sNamespace,
[string]$sInstanceQuery)

$oInstance = Get-CimInstance -ComputerName $sTargetComputer -Namespace $sNamespace -Query ("Select * from "+$sInstanceQuery) -ErrorAction SilentlyContinue

return $oInstance
}

#---------------------------------------------------------------------------
# Executes the WMI query and returns the result set.
#---------------------------------------------------------------------------
Function WMIExecQuery
{
param ([string]$sTargetComputer,
[string]$sNamespace,
[string]$sQuery)

$error.Clear()

# !!! Refactoring comment:
# Original VBScript only tries to connect to the namespace. Piping to get only the first one saves time.
$oWMI = Get-CimClass -ComputerName $sTargetComputer -Namespace $sNamespace -ErrorAction SilentlyContinue | select -First 1
if ($error.Count -gt 0)
{
$msg = "Unable to open WMI Namespace 'winmgmts:\\" + $sTargetComputer + "\" + $sNamespace + "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists."
ThrowScriptError $msg, $error[0]
}

$oQuery = Get-CimInstance -ComputerName $sTargetComputer -Namespace $sNamespace -Query $sQuery -ErrorAction SilentlyContinue
if ($error.Count -gt 0)
{
ThrowScriptError ("The Query '" + $sQuery + "' returned an invalid result set. Please check to see if this is a valid WMI Query.") $error[0]
}

return $oQuery
}

#---------------------------------------------------------------------------
# Executes the WMI query and returns the result set, no abort version.
#---------------------------------------------------------------------------
Function WMIExecQueryNoAbort
{
param ([string]$sTargetComputer,
[string]$sNamespace,
[string]$sQuery)

$oQuery = Get-CimInstance -ComputerName $sTargetComputer -Namespace $sNamespace -Query $sQuery -ErrorAction SilentlyContinue

return $oQuery
}

#---------------------------------------------------------------------------
# Creates an event and sends it back to the mom server.
#---------------------------------------------------------------------------
Function ThrowScriptErrorNoAbort
{
param ([string]$sMessage,
[System.Management.Automation.ErrorRecord]$oErr)
# Retrieve the name of this (running) script
$ScriptFileName = $MyInvocation.ScriptName

if ($oErr -ne $null)
{
$sMessage = $sMessage + ". " + $oErr.ErrorDetails
}

$momAPI.LogScriptEvent($ScriptFileName, $g_ErrorEventNumber, $EVENT_TYPE_ERROR, $sMessage)

Write-Host $sMessage
}

#---------------------------------------------------------------------------
# Creates an event and sends it back to the mom server.
#---------------------------------------------------------------------------
Function ThrowScriptError
{
param ([string]$sMessage,
[System.Management.Automation.ErrorRecord]$oErr)
ThrowScriptErrorNoAbort $sMessage $oErr
exit
}

#---------------------------------------------------------------------------
# Outputs to file and echo for debugging purposes
#---------------------------------------------------------------------------
Function TraceLogMessage
{
param ([string]$sMessage)

Write-Host $sMessage

If ($g_DebugFlag -eq $true)
{
# Retrieve the name of this (running) script
$ScriptFileName = $MyInvocation.ScriptName

$momAPI.LogScriptEvent($ScriptFileName, $g_TraceEventNumber, $EVENT_TYPE_INFORMATION, $sMessage)
}
}

#---------------------------------------------------------------------------
# Verifies the expression. If equals to False then generates an error and quits the script
# Usage:
# Verify Not WMISet Is Nothing, "WMISet is invalid!"
# Verify WMISet.Count = 1, "Invalid quantity of services with name 'Server' (qty = " &amp; WMISet.Count &amp; ")."
#---------------------------------------------------------------------------
Function Verify
{
param ([bool]$bBool,
[string]$sMessage)

If ($bBool -eq $false)
{
ThrowScriptError $sMessage $null
}
}

Function GetRegistryKeyValue
{
param ([string]$keyPath,
[string]$key)

$error.Clear()

$strKeyValue = Get-ItemProperty -Path $keyPath -Name $key -ErrorAction SilentlyContinue
if ($error.Count -gt 0)
{
ThrowScriptError ("An error occurred while reading the registry: '" + $keyPath + $key + "'") $error[0]
}
return $strKeyValue.$key
}


#---------------------------------------------------------------------------
# Function: ExpressedInMB
# Usage:
# Parameter (SizeInBytes)
# Returns the Size Expressed in MBytes
#---------------------------------------------------------------------------
Function ExpressedInMB
{
param ($SizeInBytes)

$NumberSizeExpInMB = [math]::Round($SizeInBytes / $DISKSIZE_BYTES_IN_MB, 0)
return $NumberSizeExpInMB
}


#Copyright (c) Microsoft Corporation. All rights reserved.

# Parameters that should be passed to this script
# 0 MPElement ID ($MPElement$)
# 1 Target Id for ME this rule is running against ($Target/Id$)
# 2 Computer (FQDN) that the Network Adapter will be hosted on
# 3 Computer ID (Key) that the Network Adapter will be hosted on
# 4 Should we discover disabled Network Adapters or not
# 5 Use MacAddress for discovery (true), otherwise NetConnectionID

$WIN_SRV_VNEXT_OSVer = "6.3"

Function Main()
{
$oDiscoveryData = $momAPI.CreateDiscoveryData(0, $SourceID, $ManagedEntityId)

if ((DoDiscovery $TargetComputer $TargetComputerID $oDiscoveryData $IsDiscoverDisabled $IsUseMacAddress) -ge 0)
{
$oDiscoveryData
}
}

Function DoDiscovery
{
param ([string]$sTargetComputer, [string]$sTargetComputerID, $oDisc, $IsDiscoverDisabled, $IsUseMacAddress)

$boolUseWINVNEXT = CheckByOSCurrentVersion

# Win32_NetworkAdapter is deprecated and not returning results on NanoServer
# Need to use MSFT_NetAdapter
if ((Get-Item "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels").GetValue("NanoServer") -eq 1)
{
Import-module NetAdapter # In case the module is not loaded into PSEngine

# -Physical Corresponds to "ServiceName &lt;&gt; 'VMSMP'"
$netAdapters = Get-NetAdapter -Physical | Where `
{((([System.Convert]::ToBoolean($IsUseMacAddress) -eq $true) -and ($_.MacAddress -ne $null)) `
-or (([System.Convert]::ToBoolean($IsUseMacAddress) -ne $false) -and ($_.Name -ne $null))) `
-and (([System.Convert]::ToBoolean($IsDiscoverDisabled) -eq $true) -or ($_.MediaConnectState -ne 2))}

$IsCheckNetConnectionID = IsNetConnectionIDSupported $netAdapters $true
foreach ($netAdapter in $netAdapters)
{
if ([System.Convert]::ToBoolean($IsCheckNetConnectionID) -eq $false -or $netAdapter.Name -ne "")
{
$oInstance = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.10.0.NetworkAdapter']$")
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $sTargetComputerID)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", $netAdapter.DeviceID)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Name$", $netAdapter.Name)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Description$", $netAdapter.Description)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/AdapterType$", $netAdapter.MediaType)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/Index$", $netAdapter.InterfaceIndex)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/Manufacturer$", $netAdapter.DriverProvider)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/MACAddress$", $netAdapter.MACAddress)
$serviceName = $netAdapter.DriverName
if($serviceName -ne $null)
{
$serviceNameTemp = $serviceName.Substring($serviceName.LastIndexOf("\") + 1).Split(".")
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/ServiceName$", $serviceNameTemp[0])
}else{
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/ServiceName$", "")
}

if ($netAdapter.Name -ne "")
{
$oInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $netAdapter.Name)
}
else
{
$oInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $netAdapter.DeviceID)
}

$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/PerfmonInstance$", (GetPerfmonInstance $netAdapter.InterfaceDescription) )
$oDisc.AddInstance($oInstance)
}
}
return 0;
}


$sQuery = "Win32_NetworkAdapter Where "
if ([System.Convert]::ToBoolean($IsUseMacAddress) -eq $true)
{
$sQuery += "MacAddress &lt;&gt; Null And ServiceName &lt;&gt; 'PptpMiniport' And ServiceName &lt;&gt; 'RasPppoe' And ServiceName &lt;&gt; 'VMSMP'"
}
else
{
$sQuery += "NetConnectionID &lt;&gt; Null And ServiceName &lt;&gt; 'VMSMP'"
}

# The Network Adapter information does not get populated correctly under Server 2008 Core.
# The NetConnectionStatus parameter is always NULL, so under Server 2008 Core this discovery
# will return all Network Adapters - both enabled and disabled.
# For more information see bugs "Windows OS Bugs", #2030782 &amp; "Windows 7", #119223
if ([System.Convert]::ToBoolean($IsDiscoverDisabled) -eq $false)
{
$sQuery += " And NetConnectionStatus &lt;&gt; 0"
}

$WMISetNetAdapter = WMIGetInstance $sTargetComputer "root\cimv2" $sQuery

# If at least one network adapter has NetConnectionID then it is supported.
# In this case we should discover network adapters only with NetConnectionID &lt;&gt; "".
$IsCheckNetConnectionID = IsNetConnectionIDSupported $WMISetNetAdapter $false

foreach ($owObjNetAdapter in $WMISetNetAdapter)
{
$sNetConnectionID = $owObjNetAdapter.NetConnectionID

if ([System.Convert]::ToBoolean($IsCheckNetConnectionID) -eq $false -or $sNetConnectionID -ne "")
{
$oInstance = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.10.0.NetworkAdapter']$")
$sDeviceID = $owObjNetAdapter.DeviceID

$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $sTargetComputerID)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", $sDeviceID)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Name$", $owObjNetAdapter.Name)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Description$", $owObjNetAdapter.Description)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/AdapterType$", $owObjNetAdapter.AdapterType)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/Index$", $owObjNetAdapter.Index)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/Manufacturer$", $owObjNetAdapter.Manufacturer)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/MACAddress$", ($owObjNetAdapter.MACAddress -replace(":", "-") ) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/ServiceName$", $owObjNetAdapter.ServiceName)
if ($sNetConnectionID -ne "")
{
$oInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sNetConnectionID)
}
else
{
$oInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $sDeviceID)
}

If ($boolUseWINVNEXT -eq $true)
{
# Checks if OS is at least Windows Server vNext
# Now get the Perfmon Instance Name
$WMISetPnPEntity = WMIExecQuery $sTargetComputer "root\cimv2" ("associators of {win32_NetworkAdapter='" + $sDeviceID + "'} where ResultClass=Win32_PnPEntity")
foreach ($owObjPnPEnt in $WMISetPnPEntity)
{
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/PerfmonInstance$", (GetPerfmonInstance $owObjPnPEnt.Name) )
}

# Now get the network adapter settings
$WMISetNetAdapterConfig = WMIExecQuery $sTargetComputer "root\cimv2" ("associators of {win32_NetworkAdapter='" + $sDeviceID + "'} where ResultClass=win32_NetWorkAdapterConfiguration")
foreach ($owObjNetAdpCnf in $WMISetNetAdapterConfig)
{
# Get DeviceID GUID for match with MSFT_NetAdapter
$KeySettingID = $owObjNetAdpCnf.SettingID

$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/DHCPEnabled$", (GetPerfmonInstance $owObjNetAdpCnf.DHCPEnabled) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/DHCPServer$", (GetPerfmonInstance $owObjNetAdpCnf.DHCPServer) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/DNSDomain$", (GetPerfmonInstance $owObjNetAdpCnf.DNSDomain) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/IPAddress$", (GetPerfmonInstance $owObjNetAdpCnf.IPAddress) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.NetworkAdapter']/IPSubnet$", (GetPerfmonInstance $owObjNetAdpCnf.IPSubnet) )

# Get the property value for SlotID from MSFT_NetAdapterHardwareInfoSettingData
$WMISetNetAdapterHrdwInfo = WMIGetInstance $sTargetComputer "root\StandardCimv2" ("MSFT_NetAdapterHardwareInfoSettingData where InstanceID='" + $KeySettingID + "'")

foreach ($owObjNetAdtHrdInf in $WMISetNetAdapterHrdwInfo)
{
$oInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.10.0.NetworkAdapter']/SlotNumber$", (GetPerfmonInstance $owObjNetAdtHrdInf.SlotNumber) )
}
}

}

$oDisc.AddInstance($oInstance)
}
}
return 0
}

Function GetPerfmonInstance($sName)
{
$sName = $sName -replace("\(","[")
$sName = $sName -replace("\)","]")
$sName = $sName -replace("/","_")
$sName = $sName -replace("#","_")
$temp = ""
if($sName.GetType().BaseType.Name -eq "Array")
{
foreach($name in $sName)
{
if($temp -eq "")
{
$temp = $name
}else{
$temp = $temp + "," + $name
}
}
}
if($temp -ne ""){
$sName = $temp
}
return $sName
}

Function IsNetConnectionIDSupported($WMISet, $IsMsftNetAdapter)
{
foreach ($owObj in $WMISet)
{
if (($IsMsftNetAdapter -eq $true -and $owObj.Name -ne "") -or ($IsMsftNetAdapter -eq $false -and $owObj.NetConnectionID -ne ""))
{
return $true
}
}
return $false
}

#******************************************************************************
# FUNCTION: CheckByOSCurrentVersion
# DESCRIPTION: Returns True if the Registry Key for CurrentVersion
# is equal the target OS Versions Number.
# RETURNS: Boolean: True, if build is greater or equal than the given number
#******************************************************************************
Function CheckByOSCurrentVersion() #As Boolean
{
$strCurrentOSVer = GetRegistryKeyValue "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" "CurrentVersion"

if ($strCurrentOSVer -eq $WIN_SRV_VNEXT_OSVer)
{
return $true
}
else
{
return $false
}
}

Main
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>SourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>TargetComputer</Name>
<Value>$Config/ComputerName$</Value>
</Parameter>
<Parameter>
<Name>TargetComputerID</Name>
<Value>$Config/ComputerID$</Value>
</Parameter>
<Parameter>
<Name>IsDiscoverDisabled</Name>
<Value>$Config/DiscoverDisabledNetworkAdapters$</Value>
</Parameter>
<Parameter>
<Name>IsUseMacAddress</Name>
<Value>$Config/UseMacAddress$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="ScriptProbe">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>