Origen de datos de detección de discos lógicos de Windows
Microsoft.Windows.Server.10.0.LogicalDiskDiscovery.ModuleType (DataSourceModuleType)
Element properties: Member Modules:
Overrideable Parameters:
Source Code: <DataSourceModuleType ID="Microsoft.Windows.Server.10.0.LogicalDiskDiscovery.ModuleType" RunAs="System!System.PrivilegedMonitoringAccount" 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:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
</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="Microsoft.Windows.Server.10.0.PowerShellDiscoveryProbe">
<ScriptName>Microsoft.Windows.Server.10.0.LogicalDiskDiscovery.ModuleType.ps1</ScriptName>
<PSparam>param ($SourceID, $ManagedEntityId, $TargetComputer, $TargetComputerID)</PSparam>
<ScriptBody><Script>
#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 Mount Point will be hosted on
# 3 Computer ID (Key) that the Mount Point will be hosted on
# 4 MP Element to be discovered (version-specific type)
Function Main()
{
$ClusterVolumes = @{}
$IsCluster = CheckCluster $TargetComputer
if ($IsCluster -eq $true)
{
$ClusterVolumes = GetClusterDiskCollection $TargetComputer
}
$oDiscoveryData = $momAPI.CreateDiscoveryData(0, $SourceID, $ManagedEntityId)
if ((DoDiscovery $TargetComputer $TargetComputerID $oDiscoveryData $IsCluster $ClusterVolumes) -ne 0)
{
$oDiscoveryData = $momAPI.CreateDiscoveryData(0, $SourceID, $ManagedEntityId)
$oDiscoveryData.IsSnapshot = $false
}
$oDiscoveryData
}
Function DoDiscovery
{
param ([string]$sTargetComputer, [string]$sTargetComputerID, $oDisc, [bool]$IsCluster, [hashtable]$ClusterVolumes)
if($null -eq $oDisc)
{
return 0
}
$error.Clear()
$WMISet = WMIGetInstanceNoAbort $sTargetComputer "root\cimv2" "Win32_LogicalDisk WHERE (DriveType=3 or DriveType=6) and FileSystem!=null"
if (0 -ne $error.Count)
{
return 1
}
$ErrorActionPreference="SilentlyContinue"
$error.Clear()
$errorCount = 0
foreach ($owObj in $WMISet)
{
$sDeviceId = $owObj.DeviceID
$IsClusterDisk = CheckIsClusterDisk $sDeviceId $owObj.VolumeSerialNumber $IsCluster $ClusterVolumes
if ($IsClusterDisk -eq $false -and $false -eq [string]::IsNullOrEmpty($sDeviceId))
{
$VolumeName = Get-StringProperty -Property $owObj.VolumeName
$oInstance = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.10.0.LogicalDisk']$")
$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$", $sDeviceId)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Description$", $owObj.Description)
$oInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDisk']/VolumeName$", $VolumeName)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/FileSystem$", $owObj.FileSystem)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/Compressed$", $owObj.Compressed)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/Size$", $owObj.Size)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/SizeNumeric$", -1)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/SizeInMBs$", (ExpressedInMB $owObj.Size) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/DriveType$", $owObj.DriveType)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/SupportsDiskQuota$", $owObj.SupportsDiskQuotas)
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/QuotasDisabled$", ((Get-Quota -QuotasDisabled $owObj.QuotasDisabled)) )
$oInstance.AddProperty("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.LogicalDisk']/SupportsFileBasedCompression$", $owObj.SupportsFileBasedCompression)
if (0 -eq $error.Count)
{
$oDisc.AddInstance($oInstance)
}
}
$errorCount += $error.Count
$error.Clear()
}
return $errorCount
}
Function Get-Quota ($QuotasDisabled)
{
If ([string]::IsNullOrEmpty($QuotasDisabled))
{
return "true"
}
$quota = Convert-ToBoolean -sBool $QuotasDisabled
$quota = Get-StringProperty -Property $quota.ToString()
return $quota
}
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>
</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>