仮想ネットワーク関係の検出 DataSource モジュール

Microsoft.Windows.HyperV.Discovery.VirtualNetworkContainsNetworkAdapterDiscoveryDataSourceModule (DataSourceModuleType)

Microsoft Windows Hyper-V 2016 および 1709+ 仮想ネットワーク関係の検出 DataSource モジュール

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityPublic
RunAsSystem.PrivilegedMonitoringAccount
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DataSource DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$間隔 (秒)間隔 (秒)
TimeoutSecondsint$Config/TimeoutSeconds$タイムアウト (秒)タイムアウト (秒)
SyncTimestring$Config/SyncTime$同期時刻同期時刻

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.HyperV.Discovery.VirtualNetworkContainsNetworkAdapterDiscoveryDataSourceModule" Accessibility="Public" RunAs="System!System.PrivilegedMonitoringAccount" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="SyncTime" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SyncTime" Selector="$Config/SyncTime$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DataSource" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ScriptName>DiscoverHyperVVirtualNetworkContainsNetworkAdapter.ps1</ScriptName>
<ScriptBody><Script>
# DiscoverHyperVVirtualNetworkContainsNetworkAdapter.ps1
# Copyright (c) Microsoft Corporation. All rights reserved.

param(
[Parameter(Mandatory=$true)]
[string]$SourceId,

[Parameter(Mandatory=$true)]
[string]$ManagedEntityId,

[Parameter(Mandatory=$true)]
[string]$ComputerIdentity,

[Parameter(Mandatory=$true)]
[string]$NetworkId,

[Parameter(Mandatory=$true)]
[string]$PortId
)

$momAPI = new-object -comObject MOM.ScriptAPI

$oDiscoveryData = $momAPI.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)

$DeviceID = gcim -Class "Win32_NetworkAdapter" -Filter "GUID='$PortId'" | Select DeviceID

$oNIC = $oDiscoveryData.CreateClassInstance("$MPElement[Name='Windows!Microsoft.Windows.ComputerNetworkAdapter']$")
$oNIC.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", $DeviceID)
$oNIC.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ComputerIdentity)

#Create Virtual External Network instance
$oInstance = $oDiscoveryData.CreateClassInstance("$MPElement[Name='HVLib!Microsoft.Windows.HyperV.VirtualExternalNetwork']$")
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ComputerIdentity)
$oInstance.AddProperty("$MPElement[Name='HVLib!Microsoft.Windows.HyperV.ServerRole']/ServerId$", $ComputerIdentity)
$oInstance.AddProperty("$MPElement[Name='HVLib!Microsoft.Windows.HyperV.VirtualNetwork']/NetworkId$", $NetworkId)

#Create relationship
$oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='HVLib!Microsoft.Windows.HyperV.VirtualExternalNetwork.Contains.Microsoft.Windows.Server.NetworkAdapter']$")
$oRelationship.Source = $oInstance
$oRelationship.Target = $oNIC
$oDiscoveryData.AddInstance($oRelationship)

$oDiscoveryData.IsSnapShot = $true
$momAPI.Return($oDiscoveryData)
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>SourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>ComputerIdentity</Name>
<Value>$Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>NetworkId</Name>
<Value>$Target/Property[Type="HVLib!Microsoft.Windows.HyperV.VirtualNetwork"]/NetworkId$</Value>
</Parameter>
<Parameter>
<Name>PortId</Name>
<Value>$Target/Property[Type="HVLib!Microsoft.Windows.HyperV.VirtualExternalNetwork"]/ExternalDeviceId$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DataSource"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>