Module DataSource de détection SGH

Microsoft.Windows.GuardedFabric.10.0.DataSource.DiscoverHgsServer (DataSourceModuleType)

Module DataSource pour la détection de serveurs SGH

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
Scheduler DataSource System.Discovery.Scheduler Default
PowerShellServerDiscoveryProbe ProbeAction Microsoft.Windows.PowerShellDiscoveryProbe Default
RegistryProbe ProbeAction Microsoft.Windows.RegistryProbe Default
WMIProbe ProbeAction Microsoft.Windows.WmiProbe Default
Filter ConditionDetection System.ExpressionFilter Default
Filter2 ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Intervalle en secondesIntervalle pendant lequel le planificateur de détection s’exécute en secondes.
TimeoutSecondsint$Config/TimeoutSeconds$Détection du serveur SGH (secondes)Durée maximale du script de détection (en secondes).
ComputerPrincipalNamestring$Config/ComputerPrincipalName$Nom de l’ordinateurNom de l’ordinateur sur lequel la détection est exécutée.

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.GuardedFabric.10.0.DataSource.DiscoverHgsServer" Accessibility="Internal">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:unsignedInt"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:unsignedInt"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ComputerPrincipalName" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="ComputerPrincipalName" Selector="$Config/ComputerPrincipalName$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="PowerShellServerDiscoveryProbe" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>Microsoft.Windows.GuardedFabric.10.0.Discovery.HgsServer.ps1</ScriptName>
<ScriptBody><Script># Microsoft.Windows.GuardedFabric.10.0.Discovery.HgsServer.ps1
# Copyright (c) Microsoft Corporation. All rights reserved.

param($sourceID,$managedEntityID, $computerName)

$api = New-Object -ComObject 'MOM.ScriptAPI'
$discoveryData = $api.CreateDiscoveryData(0, $sourceID, $managedEntityId)

#Get server data as ordered dictionary
try
{
$getInfo = Get-HgsServer -ErrorAction Stop
$clusterInfo = (Get-Cluster).Name
}
catch
{
$getInfo = @{}
}
if($getInfo.Count -ne 0)
{
$serverInstance = $discoveryData.CreateClassinstance("$MPElement[Name='Microsoft.Windows.GuardedFabric.10.0.ComputerRole.HgsServer']$")
$attUrl = ($getInfo.AttestationUrl |? {$_.Scheme -eq 'http'}).AbsoluteUri.ToString()
$keyUrl = ($getInfo.KeyProtectionUrl |? {$_.Scheme -eq 'http'}).AbsoluteUri.ToString()
#PROPERTIES


# Take substring if the length is greater than 256, bc SCOM agent can't handle anything greater
if ($attUrl.Length -gt 256)
{
$attUrl = $attUrl.SubString(0,253) + "..."
}

if ($keyUrl.Length -gt 256)
{
$attUrl = $attUrl.SubString(0,253) + "..."
}

$serverInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",$computerName)
$serverInstance.AddProperty("$MPElement[Name='Microsoft.Windows.GuardedFabric.10.0.ComputerRole.HgsServer']/ClusterName$", $clusterInfo)
$serverInstance.AddProperty("$MPElement[Name='Microsoft.Windows.GuardedFabric.10.0.ComputerRole.HgsServer']/AttestationOperationMode$", $getInfo.AttestationOperationMode.ToString())
$serverInstance.AddProperty("$MPElement[Name='Microsoft.Windows.GuardedFabric.10.0.ComputerRole.HgsServer']/AttestationURL$", $attUrl)
$serverInstance.AddProperty("$MPElement[Name='Microsoft.Windows.GuardedFabric.10.0.ComputerRole.HgsServer']/KeyProtectionURL$", $keyUrl)
$serverInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)

# Create Computer Class
$computerRole = $discoveryData.CreateClassinstance("$MPElement[Name='Microsoft.Windows.GuardedFabric.10.0.ComputerRole']$")
$computerRole.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",$computerName)
$computerRole.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $computerName)

#ADD TO DISCOVERY DATA
$discoveryData.AddInstance($computerRole)
$discoveryData.AddInstance($serverInstance)
#$api.LogScriptEvent("HgsServerDiscovery.ps1", 3280, 0, "HGS Server Discovery Script discovered server instance on $computerName, running in HGS Cluster $($clusterInfo) on operation mode $($getInfo.AttestationOperationMode.ToString())")
}
else
{
$discoveryData.IsSnapshot = $true
#$api.LogScriptEvent("HgsServerDiscovery.ps1", 3281, 0, "HGS Server discovery did not find that $computerName is running in the HGS Server Role.")
}
# Return found data
$discoveryData</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>computerName</Name>
<Value>$Config/ComputerPrincipalName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
</ProbeAction>
<ProbeAction ID="RegistryProbe" TypeID="Windows!Microsoft.Windows.RegistryProbe">
<ComputerName>$Target/Property[Type='Windows!Microsoft.Windows.Computer']/NetworkName$</ComputerName>
<RegistryAttributeDefinitions>
<RegistryAttributeDefinition>
<AttributeName>WindowsCurrentVersion</AttributeName>
<Path>SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion</Path>
<PathType>1</PathType>
<AttributeType>1</AttributeType>
</RegistryAttributeDefinition>
</RegistryAttributeDefinitions>
</ProbeAction>
<ProbeAction ID="WMIProbe" TypeID="Windows!Microsoft.Windows.WmiProbe">
<NameSpace>\\$Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$\root\cimv2</NameSpace>
<Query>select Version from Win32_OperatingSystem</Query>
</ProbeAction>
<ConditionDetection ID="Filter" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Values/WindowsCurrentVersion</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">6.3</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="Filter2" TypeID="System!System.ExpressionFilter">
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Version']</XPathQuery>
</ValueExpression>
<Operator>MatchesRegularExpression</Operator>
<Pattern>^(10.0.*|6.4.*|6.3.*|6.2.*)$</Pattern>
</RegExExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<Composition>
<Node ID="PowerShellServerDiscoveryProbe">
<Node ID="Filter2">
<Node ID="WMIProbe">
<Node ID="Filter">
<Node ID="RegistryProbe">
<Node ID="Scheduler"/>
</Node>
</Node>
</Node>
</Node>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>