Storage Objects Discovery Data Source

Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.Discovery.DS (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsInterval Seconds
TimeoutSecondsint$Config/TimeoutSeconds$Timeout SecondsTimeout Seconds

Source Code:

<DataSourceModuleType ID="Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.Discovery.DS" Accessibility="Internal">
<Configuration>
<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"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerName" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<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="DiscoveryProbe" TypeID="Windows!Microsoft.Windows.PowerShellDiscoveryProbe">
<ScriptName>StorageObjectsDiscovery.DS.ps1</ScriptName>
<ScriptBody><Script># Creates discovery data with Storage Objects
# else returns empty discovery data
Param( [String] $ElementID,
[String] $TargetID,
[String] $ComputerName,

[String] $StorageProviderClassID,
[String] $StorageProviderIDPropertyID,
[String] $StorageProviderTypePropertyID,
[String] $StorageProviderDescriptionPropertyID,

[String] $StorageArrayClassID,
[String] $StorageArrayIDPropertyID,
[String] $StorageArrayDescriptionPropertyID,
[String] $StorageArrayFirmwareVersionPropertyID,
[String] $StorageArrayManufacturePropertyID,
[String] $StorageArrayModelPropertyID,
[String] $StorageArraySerialNumberPropertyID,
[String] $StorageSubsystemUniqueIDPropertyID,
[String] $StorageArrayClusterNamePropertyID,

[String] $StoragePoolClassID,
[String] $StoragePoolIDPropertyID,
[String] $StoragePoolDescriptionPropertyID,
[String] $StoragePoolPrimordialPropertyID,
[String] $StoragePoolTotalManagedSpacePropertyID,
[String] $StoragePoolProvisioningTypeDefaultPropertyID,
[String] $StoragePoolSupportedProvisioningTypesPropertyID,
[String] $StoragePoolStorageClassificationPropertyID,
[String] $StoragePoolStorageOverProvisionPercentID,

[String] $StorageLogicalUnitClassID,
[String] $StorageLogicalUnitIDPropertyID,
[String] $StorageLogicalUnitDescriptionPropertyID,
[String] $StorageLogicalUnitBlockSizePropertyID,
[String] $StorageLogicalUnitNumberOfBlocksPropertyID,
[String] $StorageLogicalUnitThinlyProvisionedPropertyID,
[String] $StorageLogicalUnitPrimordialPropertyID,
[String] $StorageLogicalUnitTotalCapacityPropertyID,
[String] $StorageLogicalUnitRemainingCapacityPropertyID,
[String] $StorageLogicalUnitStorageClassificationPropertyID,
[String] $StorageLogicalUnitVirtualDiskUniqueIDPropertyID,

[String] $VMHostDiskClassID,
[String] $VMHostDiskIDPropertyID,
[String] $VMHostDiskCapacityPropertyID,
[String] $VMHostDiskIsClusteredPropertyID,
[String] $VMHostDiskIsSanAttachedPropertyID,
[String] $VMHostDiskIsPassThroughCapablePropertyID,
[String] $VMHostDiskLocationPropertyID,
[String] $VMHostDiskDiskIDPropertyID,
[String] $VMHostDiskSMLunIDPropertyID,
[String] $VMHostDiskAvailableCapacityPropertyID,


[String] $HostVolumeClassID,
[String] $HostVolumeIDPropertyID,
[String] $HostVolumeMountPointsPropertyID,
[String] $HostVolumeCapacityPropertyID,
[String] $HostVolumeVolumeLabelPropertyID,
[String] $HostVolumeIsClusteredPropertyID,
[String] $HostVolumeIsClusterSharedVolumePropertyID,
[String] $HostVolumeFreeSpacePropertyID,
[String] $HostVolumeIsAvailableForPlacementPropertyID,
[String] $HostVolumeClassificationPropertyID,

[String] $VHDClassID,
[String] $VHDIDPropertyID,
[String] $VHDDescriptionPropertyID,
[String] $VHDVHDTypePropertyID,
[String] $VHDVHDFormatTypePropertyID,
[String] $VHDVirtualizationPlatformPropertyID,
[String] $VHDMaximumSizePropertyID,
[String] $VHDLocationPropertyID,
[String] $VHDCurrentSizePropertyID,

[String] $FileShareClassID,
[String] $FileShareIDPropertyID,
[String] $FileShareDescriptionPropertyID,
[String] $FileShareIsAvailableForPlacementPropertyID,
[String] $FileShareIsManagedPropertyID,
[String] $HostAssociationsPropertyID,
[String] $ClusterAssociationsPropertyID,
[String] $FileShareStorageClassificationPropertyID,
[String] $FileShareSharePathPropertyID,
[String] $FileShareStorageVolumeIDPropertyID,
[String] $FileShareFreeSpacePropertyID,
[String] $FileShareCapacityPropertyID,
[String] $FileShareMSContainsVirtualMachineRelationID,

[String] $VirtualMachineClassID,
[String] $VirtualMachineIDPropertyID,
[String] $StoragePoolGroupClassID,
[String] $StoragePoolGroupContainsStoragePoolMSClassID,
[String] $VMMServerPropertyID,
[String] $VMHostIDPropertyID,
[String] $StorageLogicalUnitContainsVMHostDiskClassID,
[String] $VMHostDiskContainsHostVolumeClassID,
[String] $VDDClassID,
[String] $VDDIDPropertyID,
[String] $ComputerPrincipalNameKey,
[String] $EntityDisplayNameKey,
[String] $VirtualDiskDriveReferencesVHDClassID,
[String] $VHDReferencesHostVolumeClassID,
[String] $VirtualDiskDriveReferencesVMHostDiskClassID,

[String] $FileServerClassID,
[String] $FileServerIDPropertyID,
[String] $FileServerVMMServerPropertyID,
[String] $FileServerClusterNamePropertyID,
[String] $FileServerDescriptionPropertyID,
[String] $FileServerTypePropertyID,
[String] $FileServerStorageNodesPropertyID,
[String] $FileServerFreeSpacePropertyID,
[String] $FileServerCapacityPropertyID,
[String] $FileServerModelPropertyID,
[String] $FileServerManufacturerPropertyID,
[String] $FileServerSerialNumberPropertyID,
[String] $ArrayReferencesFileServerClassID,

[String] $EnclosureClassID,
[String] $EnclosureDeviceIDPropertyID,
[String] $EnclosureUniqueIDPropertyID,
[String] $EnclosureVMMServerPropertyID,
[String] $EnclosureModelPropertyID,
[String] $EnclosureManufacturerPropertyID,
[String] $EnclosureSerialNumberPropertyID,
[String] $EnclosureFirmwareVersionPropertyID,
[String] $EnclosureNumberOfSlotsPropertyID,
[String] $StoragePoolMSContainsEnclosureRelationID,
[String] $ArrayReferencesEnclosureID,

[String] $StoragePoolMSClassID,
[String] $StoragePoolMSIDPropertyID,
[String] $StoragePoolMSDescriptionPropertyID,
[String] $StoragePoolMSPrimordialPropertyID,
[String] $StoragePoolMSTotalManagedSpacePropertyID,
[String] $StoragePoolMSProvisioningTypeDefaultPropertyID,
[String] $StoragePoolMSSupportedProvisioningTypesPropertyID,
[String] $StoragePoolMSStorageClassificationPropertyID,
[String] $StoragePoolMSStorageOverProvisionPercentID,
[String] $StoragePoolMSContainsStoragePoolRelationID,
[String] $StoragePoolMSContainsStoragePoolSpacesRelationID,

[String] $StoragePoolSpacesClassID,
[String] $StoragePoolSpacesUniqueIDPropertyID,
[String] $StoragePoolSpacesVMMServerPropertyID,
[String] $StoragePoolSpacesProvisioningTypeDefaultPropertyID,
[String] $StoragePoolSpacesResiliencySettingNameDefaultPropertyID,
[String] $StoragePoolSpacesSupportsDeduplicationPropertyID,
[String] $StoragePoolSpacesIsClusteredPropertyID,
[String] $StoragePoolSpacesIsReadOnlyPropertyID,
[String] $StoragePoolSpacesDescriptionPropertyID,

[String] $FileShareMSClassID,
[String] $FileShareMSIDPropertyID,
[String] $FileShareMSDescriptionPropertyID,
[String] $FileShareMSSharePathPropertyID,
[String] $FileShareMSStorageVolumeIDPropertyID,
[String] $FileShareMSStorageClassificationPropertyID,
[String] $FileShareMSIsManagedPropertyID,
[String] $FileShareMSClusterNamePropertyID,
[String] $FileShareMSUniqueIDPropertyID,
[String] $FileShareMSVMMServerPropertyID,
[String] $FileShareMSContainsFileShareVMMRelationID,
[String] $FileShareMSContainsFileShareBaseRelationID,

[String] $FileShareSMBClassID,
[String] $FileShareSMBIDPropertyID,
[String] $FileShareSMBDescriptionPropertyID,
[String] $FileShareSMBVMMServerPropertyID,
[String] $FileShareSMBShareNamePropertyID,
[String] $FileShareSMBSharePathPropertyID,
[String] $FileShareSMBStorageVolumeIDPropertyID,
[String] $FileShareSMBStorageFileServerPropertyID,
[String] $FileShareSMBFreeSpacePropertyID,
[String] $FileShareSMBCapacityPropertyID,

[String] $StorageVolumeMSClassID,
[String] $StorageVolumeMSIDPropertyID,
[String] $StorageVolumeMSUniqueIDPropertyID,
[String] $StorageVolumeMSCapacityPropertyID,
[String] $StorageVolumeMSVolumeLabelPropertyID,
[String] $StorageVolumeMSIsCSVPropertyID,
[String] $StorageVolumeMSFreeSpacePropertyID,
[String] $StorageVolumeMSClassificationPropertyID,
[String] $StorageVolumeMSClusterNamePropertyID,
[String] $StorageVolumeMSVMMServerPropertyID,

[String] $domain,
[String] $username,
[String] $password
)

Function AddTraceMessage
{
param($msg)

$timeStamp = (get-date -format "HH:mm:ss:fff");
$script:traceMsg = $script:traceMsg + "`n[" + $timeStamp + "]" + $msg;
$momAPI.LogScriptEvent("StorageObjectsDiscovery.DS.ps1", 108, 0, $script:traceMsg);
$script:traceMsg = ""
}


$server = $null;
$script:traceMsg = "";
$errorActionPreference = "Continue"
$momAPI = new-object -comObject MOM.ScriptAPI
$momDiscoveryData = $momAPI.CreateDiscoveryData(0, $ElementID, $TargetID)
AddTraceMessage -msg "Storage Discovery: started."
$error.Clear();
# Create Discovery Data


# Credential to use for remote connection
$cred = $null;
if($domain -AND $username -AND $password)
{
#Append domain to get domain\username
$domainUser = $domain + "\" + $username;

#Create Cred object
$securePass = ConvertTo-SecureString -AsPlainText $password -force
$cred = New-Object System.Management.Automation.PSCredential $domainUser, $securePass;
}
$error.Clear();

$session = New-PSSession -ComputerName $ComputerName -Authentication Default -Credential $cred;
if ( ($error -ne $null) -and ($error.Count -ne 0) )
{
$errorMsg = "Storage Discovery: Got errors creating a PS session to VMM." + [string] $error;
AddTraceMessage -msg $errorMsg
if ($session -ne $null)
{
Remove-PSSession $session;
}
return;
}

$scvmmServer = Invoke-Command -Session $session -ArgumentList $ComputerName, $cred -ScriptBlock { $module = get-module -name "virtualmachinemanager"; if ($module -eq $null) { Import-Module "virtualmachinemanager"; } $server = Get-SCVMMServer -ComputerName $args[0] -Credential $args[1]; $server };

if ($scvmmServer -eq $null)
{
$errorMsg = "Storage Discovery: Could not get VMM Server using Get-SCVMMServer -ComputerName " + $ComputerName + ". Ensure the server is running and responsive." ;
if ( ($error -ne $null) -and ($error.Count -ne 0) )
{
$errorMsg = $errorMsg + [string] $error;
}
AddTraceMessage -msg $errorMsg
Remove-PSSession $session;
return;
}
else
{
AddTraceMessage -msg "Storage Discovery: Got VMMServer. Module imported."
}

Try
{
#Enhance readability, create a hashtable of params to be used as named params inside remote script block
$arg = @{
ElementID = $ElementID
TargetID = $TargetID
ComputerName = $ComputerName
StorageProviderClassID = $StorageProviderClassID
StorageProviderIDPropertyID = $StorageProviderIDPropertyID
StorageProviderTypePropertyID = $StorageProviderTypePropertyID
StorageProviderDescriptionPropertyID = $StorageProviderDescriptionPropertyID

StorageArrayClassID = $StorageArrayClassID
StorageArrayIDPropertyID = $StorageArrayIDPropertyID
StorageArrayDescriptionPropertyID = $StorageArrayDescriptionPropertyID
StorageArrayFirmwareVersionPropertyID = $StorageArrayFirmwareVersionPropertyID
StorageArrayManufacturePropertyID = $StorageArrayManufacturePropertyID
StorageArrayModelPropertyID = $StorageArrayModelPropertyID
StorageArraySerialNumberPropertyID = $StorageArraySerialNumberPropertyID
StorageSubsystemUniqueIDPropertyID = $StorageSubsystemUniqueIDPropertyID
StorageArrayClusterNamePropertyID = $StorageArrayClusterNamePropertyID

StoragePoolClassID = $StoragePoolClassID
StoragePoolIDPropertyID = $StoragePoolIDPropertyID
StoragePoolDescriptionPropertyID = $StoragePoolDescriptionPropertyID
StoragePoolPrimordialPropertyID = $StoragePoolPrimordialPropertyID
StoragePoolTotalManagedSpacePropertyID = $StoragePoolTotalManagedSpacePropertyID
StoragePoolProvisioningTypeDefaultPropertyID = $StoragePoolProvisioningTypeDefaultPropertyID
StoragePoolSupportedProvisioningTypesPropertyID = $StoragePoolSupportedProvisioningTypesPropertyID
StoragePoolStorageClassificationPropertyID = $StoragePoolStorageClassificationPropertyID
StoragePoolStorageOverProvisionPercentID = $StoragePoolStorageOverProvisionPercentID

StorageLogicalUnitClassID = $StorageLogicalUnitClassID
StorageLogicalUnitIDPropertyID = $StorageLogicalUnitIDPropertyID
StorageLogicalUnitDescriptionPropertyID = $StorageLogicalUnitDescriptionPropertyID
StorageLogicalUnitBlockSizePropertyID = $StorageLogicalUnitBlockSizePropertyID
StorageLogicalUnitNumberOfBlocksPropertyID = $StorageLogicalUnitNumberOfBlocksPropertyID
StorageLogicalUnitThinlyProvisionedPropertyID = $StorageLogicalUnitThinlyProvisionedPropertyID
StorageLogicalUnitPrimordialPropertyID = $StorageLogicalUnitPrimordialPropertyID
StorageLogicalUnitTotalCapacityPropertyID = $StorageLogicalUnitTotalCapacityPropertyID
StorageLogicalUnitRemainingCapacityPropertyID = $StorageLogicalUnitRemainingCapacityPropertyID
StorageLogicalUnitStorageClassificationPropertyID = $StorageLogicalUnitStorageClassificationPropertyID
StorageLogicalUnitVirtualDiskUniqueIDPropertyID = $StorageLogicalUnitVirtualDiskUniqueIDPropertyID

VMHostDiskClassID = $VMHostDiskClassID
VMHostDiskIDPropertyID = $VMHostDiskIDPropertyID
VMHostDiskCapacityPropertyID = $VMHostDiskCapacityPropertyID
VMHostDiskIsClusteredPropertyID = $VMHostDiskIsClusteredPropertyID
VMHostDiskIsSanAttachedPropertyID = $VMHostDiskIsSanAttachedPropertyID
VMHostDiskIsPassThroughCapablePropertyID = $VMHostDiskIsPassThroughCapablePropertyID
VMHostDiskLocationPropertyID = $VMHostDiskLocationPropertyID
VMHostDiskDiskIDPropertyID = $VMHostDiskDiskIDPropertyID
VMHostDiskSMLunIDPropertyID = $VMHostDiskSMLunIDPropertyID
VMHostDiskAvailableCapacityPropertyID = $VMHostDiskAvailableCapacityPropertyID


HostVolumeClassID = $HostVolumeClassID
HostVolumeIDPropertyID = $HostVolumeIDPropertyID
HostVolumeMountPointsPropertyID = $HostVolumeMountPointsPropertyID
HostVolumeCapacityPropertyID = $HostVolumeCapacityPropertyID
HostVolumeVolumeLabelPropertyID = $HostVolumeVolumeLabelPropertyID
HostVolumeIsClusteredPropertyID = $HostVolumeIsClusteredPropertyID
HostVolumeIsClusterSharedVolumePropertyID = $HostVolumeIsClusterSharedVolumePropertyID
HostVolumeFreeSpacePropertyID = $HostVolumeFreeSpacePropertyID
HostVolumeIsAvailableForPlacementPropertyID = $HostVolumeIsAvailableForPlacementPropertyID
HostVolumeClassificationPropertyID = $HostVolumeClassificationPropertyID

VHDClassID = $VHDClassID
VHDIDPropertyID = $VHDIDPropertyID
VHDDescriptionPropertyID = $VHDDescriptionPropertyID
VHDVHDTypePropertyID = $VHDVHDTypePropertyID
VHDVHDFormatTypePropertyID = $VHDVHDFormatTypePropertyID
VHDVirtualizationPlatformPropertyID = $VHDVirtualizationPlatformPropertyID
VHDMaximumSizePropertyID = $VHDMaximumSizePropertyID
VHDLocationPropertyID = $VHDLocationPropertyID
VHDCurrentSizePropertyID = $VHDCurrentSizePropertyID

FileShareClassID = $FileShareClassID
FileShareIDPropertyID = $FileShareIDPropertyID
FileShareDescriptionPropertyID = $FileShareDescriptionPropertyID
FileShareIsAvailableForPlacementPropertyID = $FileShareIsAvailableForPlacementPropertyID
FileShareIsManagedPropertyID = $FileShareIsManagedPropertyID
HostAssociationsPropertyID = $HostAssociationsPropertyID
ClusterAssociationsPropertyID = $ClusterAssociationsPropertyID
FileShareStorageClassificationPropertyID = $FileShareStorageClassificationPropertyID
FileShareSharePathPropertyID = $FileShareSharePathPropertyID
FileShareStorageVolumeIDPropertyID = $FileShareStorageVolumeIDPropertyID
FileShareFreeSpacePropertyID = $FileShareFreeSpacePropertyID
FileShareCapacityPropertyID = $FileShareCapacityPropertyID
FileShareMSContainsVirtualMachineRelationID = $FileShareMSContainsVirtualMachineRelationID

VirtualMachineClassID = $VirtualMachineClassID
VirtualMachineIDPropertyID = $VirtualMachineIDPropertyID
StoragePoolGroupClassID = $StoragePoolGroupClassID
StoragePoolGroupContainsStoragePoolMSClassID = $StoragePoolGroupContainsStoragePoolMSClassID
VMMServerPropertyID = $VMMServerPropertyID
VMHostIDPropertyID = $VMHostIDPropertyID
StorageLogicalUnitContainsVMHostDiskClassID = $StorageLogicalUnitContainsVMHostDiskClassID
VMHostDiskContainsHostVolumeClassID = $VMHostDiskContainsHostVolumeClassID
VDDClassID = $VDDClassID
VDDIDPropertyID = $VDDIDPropertyID
ComputerPrincipalNameKey = $ComputerPrincipalNameKey
EntityDisplayNameKey = $EntityDisplayNameKey
VirtualDiskDriveReferencesVHDClassID = $VirtualDiskDriveReferencesVHDClassID
VHDReferencesHostVolumeClassID = $VHDReferencesHostVolumeClassID
VirtualDiskDriveReferencesVMHostDiskClassID = $VirtualDiskDriveReferencesVMHostDiskClassID

FileServerClassID = $FileServerClassID
FileServerIDPropertyID = $FileServerIDPropertyID
FileServerVMMServerPropertyID = $FileServerVMMServerPropertyID
FileServerClusterNamePropertyID = $FileServerClusterNamePropertyID
FileServerDescriptionPropertyID = $FileServerDescriptionPropertyID
FileServerTypePropertyID = $FileServerTypePropertyID
FileServerStorageNodesPropertyID = $FileServerStorageNodesPropertyID
FileServerFreeSpacePropertyID = $FileServerFreeSpacePropertyID
FileServerCapacityPropertyID = $FileServerCapacityPropertyID
FileServerModelPropertyID = $FileServerModelPropertyID
FileServerManufacturerPropertyID = $FileServerManufacturerPropertyID
FileServerSerialNumberPropertyID = $FileServerSerialNumberPropertyID
ArrayReferencesFileServerClassID = $ArrayReferencesFileServerClassID

EnclosureClassID = $EnclosureClassID
EnclosureDeviceIDPropertyID = $EnclosureDeviceIDPropertyID
EnclosureUniqueIDPropertyID = $EnclosureUniqueIDPropertyID
EnclosureVMMServerPropertyID = $EnclosureVMMServerPropertyID
EnclosureModelPropertyID = $EnclosureModelPropertyID
EnclosureManufacturerPropertyID = $EnclosureManufacturerPropertyID
EnclosureSerialNumberPropertyID = $EnclosureSerialNumberPropertyID
EnclosureFirmwareVersionPropertyID = $EnclosureFirmwareVersionPropertyID
EnclosureNumberOfSlotsPropertyID = $EnclosureNumberOfSlotsPropertyID
StoragePoolMSContainsEnclosureRelationID = $StoragePoolMSContainsEnclosureRelationID
ArrayReferencesEnclosureID = $ArrayReferencesEnclosureID

StoragePoolMSClassID = $StoragePoolMSClassID
StoragePoolMSIDPropertyID = $StoragePoolMSIDPropertyID
StoragePoolMSDescriptionPropertyID = $StoragePoolMSDescriptionPropertyID
StoragePoolMSPrimordialPropertyID = $StoragePoolMSPrimordialPropertyID
StoragePoolMSTotalManagedSpacePropertyID = $StoragePoolMSTotalManagedSpacePropertyID
StoragePoolMSProvisioningTypeDefaultPropertyID = $StoragePoolMSProvisioningTypeDefaultPropertyID
StoragePoolMSSupportedProvisioningTypesPropertyID = $StoragePoolMSSupportedProvisioningTypesPropertyID
StoragePoolMSStorageClassificationPropertyID = $StoragePoolMSStorageClassificationPropertyID
StoragePoolMSStorageOverProvisionPercentID = $StoragePoolMSStorageOverProvisionPercentID
StoragePoolMSContainsStoragePoolRelationID = $StoragePoolMSContainsStoragePoolRelationID
StoragePoolMSContainsStoragePoolSpacesRelationID = $StoragePoolMSContainsStoragePoolSpacesRelationID

StoragePoolSpacesClassID = $StoragePoolSpacesClassID
StoragePoolSpacesUniqueIDPropertyID = $StoragePoolSpacesUniqueIDPropertyID
StoragePoolSpacesVMMServerPropertyID = $StoragePoolSpacesVMMServerPropertyID
StoragePoolSpacesProvisioningTypeDefaultPropertyID = $StoragePoolSpacesProvisioningTypeDefaultPropertyID
StoragePoolSpacesResiliencySettingNameDefaultPropertyID = $StoragePoolSpacesResiliencySettingNameDefaultPropertyID
StoragePoolSpacesSupportsDeduplicationPropertyID = $StoragePoolSpacesSupportsDeduplicationPropertyID
StoragePoolSpacesIsClusteredPropertyID = $StoragePoolSpacesIsClusteredPropertyID
StoragePoolSpacesIsReadOnlyPropertyID = $StoragePoolSpacesIsReadOnlyPropertyID
StoragePoolSpacesDescriptionPropertyID = $StoragePoolSpacesDescriptionPropertyID

FileShareMSClassID = $FileShareMSClassID
FileShareMSIDPropertyID = $FileShareMSIDPropertyID
FileShareMSDescriptionPropertyID = $FileShareMSDescriptionPropertyID
FileShareMSSharePathPropertyID = $FileShareMSSharePathPropertyID
FileShareMSStorageVolumeIDPropertyID = $FileShareMSStorageVolumeIDPropertyID
FileShareMSStorageClassificationPropertyID = $FileShareMSStorageClassificationPropertyID
FileShareMSIsManagedPropertyID = $FileShareMSIsManagedPropertyID
FileShareMSClusterNamePropertyID = $FileShareMSClusterNamePropertyID
FileShareMSUniqueIDPropertyID = $FileShareMSUniqueIDPropertyID
FileShareMSVMMServerPropertyID = $FileShareMSVMMServerPropertyID
FileShareMSContainsFileShareVMMRelationID = $FileShareMSContainsFileShareVMMRelationID
FileShareMSContainsFileShareBaseRelationID = $FileShareMSContainsFileShareBaseRelationID

FileShareSMBClassID = $FileShareSMBClassID
FileShareSMBIDPropertyID = $FileShareSMBIDPropertyID
FileShareSMBDescriptionPropertyID = $FileShareSMBDescriptionPropertyID
FileShareSMBVMMServerPropertyID = $FileShareSMBVMMServerPropertyID
FileShareSMBShareNamePropertyID = $FileShareSMBShareNamePropertyID
FileShareSMBSharePathPropertyID = $FileShareSMBSharePathPropertyID
FileShareSMBStorageVolumeIDPropertyID = $FileShareSMBStorageVolumeIDPropertyID
FileShareSMBStorageFileServerPropertyID = $FileShareSMBStorageFileServerPropertyID
FileShareSMBFreeSpacePropertyID = $FileShareSMBFreeSpacePropertyID
FileShareSMBCapacityPropertyID = $FileShareSMBCapacityPropertyID
StorageVolumeMSClassID = $StorageVolumeMSClassID
StorageVolumeMSIDPropertyID = $StorageVolumeMSIDPropertyID
StorageVolumeMSUniqueIDPropertyID = $StorageVolumeMSUniqueIDPropertyID
StorageVolumeMSCapacityPropertyID = $StorageVolumeMSCapacityPropertyID
StorageVolumeMSVolumeLabelPropertyID = $StorageVolumeMSVolumeLabelPropertyID
StorageVolumeMSIsCSVPropertyID = $StorageVolumeMSIsCSVPropertyID
StorageVolumeMSFreeSpacePropertyID = $StorageVolumeMSFreeSpacePropertyID
StorageVolumeMSClassificationPropertyID = $StorageVolumeMSClassificationPropertyID
StorageVolumeMSClusterNamePropertyID = $StorageVolumeMSClusterNamePropertyID
StorageVolumeMSVMMServerPropertyID = $StorageVolumeMSVMMServerPropertyID
}
$scriptBlockArgs = @($arg);

$ParamsTrace = ""
foreach ($key in $arg.Keys)
{
$ParamsTrace = $ParamsTrace + " -" + $key + " `"" + $arg[$key] + "`"";
}

AddTraceMessage -msg $ParamsTrace

$scriptBlock = {
Function AddTraceMessage
{
param($msg)
$timeStamp = (get-date -format "HH:mm:ss:fff");
$global:blockTraceMsg = $global:blockTraceMsg + "`n[RemoteSession]: " + "[" + $timeStamp + "]" + $msg;
}

Function CreateFileServerInstances
{
param($node, $nodeNames, $fileServer, $storageArrayMap)

#create a clustered fileserver object for the node
$FileServerObject = CreateClassInstance -classType $arg["FileServerClassID"];
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerIDPropertyID"] -propertyValue $node.UniqueId; #key property
AddProperty -classInstance $FileServerObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $node.Name; #host key property
AddProperty -classInstance $FileServerObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $node.Name; #fs node name
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerVMMServerPropertyID"] -propertyValue $arg["ComputerName"];
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerClusterNamePropertyID"] -propertyValue $fileServer.Name;
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerDescriptionPropertyID"] -propertyValue $node.Description;
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerTypePropertyID"] -propertyValue $fileServer.FileServerType.ToString();
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerStorageNodesPropertyID"] -propertyValue $nodeNames;
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerFreeSpacePropertyID"] -propertyValue $fileServer.FreeSpace.ToString();
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerCapacityPropertyID"] -propertyValue $fileServer.Capacity.ToString();
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerModelPropertyID"] -propertyValue $fileServer.Model;
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerManufacturerPropertyID"] -propertyValue $fileServer.Manufacturer;
AddProperty -classInstance $FileServerObject -propertyName $arg["FileServerSerialNumberPropertyID"] -propertyValue $fileServer.SerialNumber;
AddInstance -discoveryData $discoveryData -instance $FileServerObject;
$msg = "`nStorage Discovery: Created FileServer (Node Name) " + $node.Name + " ; FS Cluster Name = " + $fileServer.Name ;

if ($fileServer.StorageArray -ne $null -and $storageArrayMap[$fileServer.StorageArray.ID] -ne $null)
{
$relationship = CreateRelationshipInstance -relationshipType $arg["ArrayReferencesFileServerClassID"]
$relationship.Source = $storageArrayMap[$fileServer.StorageArray.ID]
$relationship.Target = $FileServerObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationship;
$msg = $msg + "`n Array References FileServer " + $node.Name;
}

AddTraceMessage -msg $msg
}

Function CreateStorageVolumeMSInstances
{
param($fileServer)

$volumes = $fileServer.StorageVolumes
foreach ($vol in $volumes)
{
$storageVolumeMSObject = CreateClassInstance -classType $arg["StorageVolumeMSClassID"];
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSIDPropertyID"] -propertyValue $vol.StorageVolumeId.ToString(); #key property
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSUniqueIDPropertyID"] -propertyValue $vol.UniqueId.ToString(); #key property
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $vol.Name;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSCapacityPropertyID"] -propertyValue $vol.Capacity;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSVolumeLabelPropertyID"] -propertyValue $vol.VolumeLabel;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSIsCSVPropertyID"] -propertyValue $vol.IsClusterSharedVolume;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSFreeSpacePropertyID"] -propertyValue $vol.FreeSpace;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSClassificationPropertyID"] -propertyValue $classification;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSClusterNamePropertyID"] -propertyValue $fileServer.StorageArray.SMName;
AddProperty -classInstance $storageVolumeMSObject -propertyName $arg["StorageVolumeMSVMMServerPropertyID"] -propertyValue $arg["ComputerName"];
$msg = $msg + "`nStorage Discovery: Created FileServer Volume (Top Level) " + $vol.Name + " ; FS Name = " + $fileServer.Name ;
AddInstance -discoveryData $discoveryData -instance $storageVolumeMSObject;
}

AddTraceMessage -msg $msg
}

# Create generic objects to hold discovery data
# MOMScriptAPI's DiscoveryData doesn't serialize correctly over the remote session

Function CreateDiscoveryData
{
param($sourceType, $sourceId, $managedEntityId)

$discoveryData = @{};
$discoveryData.SourceType = $sourceType;
$discoveryData.SourceId = $sourceId;
$discoveryData.ManagedEntityId = $managedEntityId;
$discoveryData.ClassInstances = New-Object &#x201C;System.Collections.Generic.List[System.Collections.Hashtable]&#x201D;;
$discoveryData.RelationshipInstances = New-Object &#x201C;System.Collections.Generic.List[System.Collections.Hashtable]&#x201D;;

return $discoveryData;
}

Function AddInstance
{
param($discoveryData, $instance)
if ($discoveryData -ne $null -and $instance -ne $null -and $instance.Properties -ne $null -and $instance.Properties.Count -gt 0)
{
$discoveryData.ClassInstances.Add($instance);
}
else
{
AddTraceMessage -msg "Invalid Object"
}
}

Function AddRelationshipInstance
{
param($discoveryData, $relationship)
if ($discoveryData -ne $null -and $relationship -ne $null -and $relationship.Source -ne $null -and $relationship.Target -ne $null)
{
$discoveryData.RelationshipInstances.Add($relationship);
}
else
{
AddTraceMessage -msg "Invalid Relationship"
}
}

Function CreateClassInstance
{
param($classType)

$classInstance = @{};
$classInstance.ClassType = $classType;
$classInstance.Properties = @{};

return $classInstance;
}

Function AddProperty
{
param($classInstance, $propertyName, $propertyValue)
if ($propertyName -ne $null -and !$classInstance.Properties.ContainsKey($propertyName))
{
if ($propertyValue -ne $null)
{
$classInstance.Properties.Add($propertyName, $propertyValue);
}
else
{
$msg = "Null Property Value for:" + $propertyName
AddTraceMessage -msg $msg
}
}
else
{
$msg = "Duplicate Entry " + $propertyName + " " + $propertyValue
AddTraceMessage -msg $msg
}
}

Function CreateRelationshipInstance
{
param($relationshipType)

$relationshipInstance = @{};
$relationshipInstance.RelationshipType = $relationshipType;
$relationshipInstance.Source = @{};
$relationshipInstance.Target = @{};

return $relationshipInstance;
}

$evt = New-Object System.Diagnostics.Eventlog("Application");
$evt.Source = "Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.Discovery";
$errorevent = [System.Diagnostics.EventLogEntryType]::Error;
$infoevent = [System.Diagnostics.EventLogEntryType]::Information;
$error.Clear();
$global:blockTraceMsg = "";
$arg = $args[0];
$discoveryData = CreateDiscoveryData -sourceId $arg["ElementID"] -managedEntityId $arg["TargetID"] -sourceType "DiscoveryData"

Try
{
# Populate discovery data
# Add storage providers
$storageProviders = @(Get-SCStorageProvider -VMMServer $server -All)
$count = 0;
foreach ($storageProvider in $storageProviders)
{
# Create Storage Provider Object and hosting relationship
$storageProviderObject = CreateClassInstance -classType $arg["StorageProviderClassID"]
AddProperty -classInstance $storageProviderObject -propertyName $arg["StorageProviderIDPropertyID"] -propertyValue $storageProvider.ID.ToString()
AddProperty -classInstance $storageProviderObject -propertyName $arg["StorageProviderTypePropertyID"] -propertyValue $storageProvider.ProviderType.ToString()
AddProperty -classInstance $storageProviderObject -propertyName $arg["StorageProviderDescriptionPropertyID"] -propertyValue $storageProvider.Description
AddProperty -classInstance $storageProviderObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"]
AddProperty -classInstance $storageProviderObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $storageProvider.Name
AddInstance -discoveryData $discoveryData -instance $storageProviderObject
$count = $count + 1
}
$trace = "Storage Discovery: Discovered " + $count + " Storage Providers."
AddTraceMessage -msg $trace
# Add storage arrays
$storageArrays = @(Get-SCStorageArray -VMMServer $server -All)
$storageArrayMap = @{};
$count = 0;
foreach ($storageArray in $storageArrays)
{
# Create Storage Array Object and hosting relationship
$storageArrayObject = CreateClassInstance -classType $arg["StorageArrayClassID"]
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageProviderIDPropertyID"] -propertyValue $storageArray.StorageProvider.ID.ToString()
AddProperty -classInstance $storageArrayObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"]
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArrayIDPropertyID"] -propertyValue $storageArray.ID.ToString()
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArrayDescriptionPropertyID"] -propertyValue $storageArray.Description
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArrayFirmwareVersionPropertyID"] -propertyValue $storageArray.FirmwareVersion
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArrayManufacturePropertyID"] -propertyValue $storageArray.Manufacturer
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArrayModelPropertyID"] -propertyValue $storageArray.Model
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArraySerialNumberPropertyID"] -propertyValue $storageArray.SerialNumber

#Adding StorageSubsystemUniqueID
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageSubsystemUniqueIDPropertyID"] -propertyValue $storageArray.UniqueId.ToString()
AddProperty -classInstance $storageArrayObject -propertyName $arg["StorageArrayClusterNamePropertyID"] -propertyValue $storageArray.SMName
AddProperty -classInstance $storageArrayObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $storageArray.Name
AddInstance -discoveryData $discoveryData -instance $storageArrayObject
$storageArrayMap.Add($storageArray.ID, $storageArrayObject);
$count = $count + 1
}
$trace = "Storage Discovery: Discovered " + $count + " Storage Arrays."
AddTraceMessage -msg $trace

# Get Storage Pool Group class instance (we will add relationships to storage pools)
$storagePoolGroupObject = CreateClassInstance -classType $arg["StoragePoolGroupClassID"]
AddProperty -classInstance $storagePoolGroupObject -propertyName $arg["VMMServerPropertyID"] -propertyValue $arg["ComputerName"]

# Add hosted storage pools
$storagePools = @(Get-SCStoragePool -VMMServer $server -All)
$msg = "Storage Discovery: Got VMM Storage Pools."
$count= 0;
foreach ($storagePool in $storagePools)
{
# Create Storage Pool Object and hosting relationship
$storagePoolObject = CreateClassInstance -classType $arg["StoragePoolClassID"]
AddProperty -classInstance $storagePoolObject -propertyName $arg["StorageProviderIDPropertyID"] -propertyValue $storagePool.StorageArray.StorageProvider.ID.ToString()
AddProperty -classInstance $storagePoolObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"]
AddProperty -classInstance $storagePoolObject -propertyName $arg["StorageArrayIDPropertyID"] -propertyValue $storagePool.StorageArray.ID.ToString()
AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolIDPropertyID"] -propertyValue $storagePool.ID.ToString()
AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolDescriptionPropertyID"] -propertyValue $storagePool.Description
AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolPrimordialPropertyID"] -propertyValue $storagePool.Primordial
AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolTotalManagedSpacePropertyID"] -propertyValue $storagePool.TotalManagedSpace
$Classification = ""
if ($storagePool.Classification -ne $null)
{
$Classification = $storagePool.Classification.ToString()
}
AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolStorageClassificationPropertyID"] -propertyValue $Classification

$storagePoolLuns = $storagePool.StorageLogicalUnits
$totalLunSize = 0
foreach($lun in $storagePoolLuns)
{
if ($lun -ne $null)
{
$totalLunSize += $lun.TotalCapacity
}
}
$overProvisionPercent = 0;
if ($storagePool.TotalManagedSpace -gt 0)
{
$overProvisionPercent = [int](($totalLunSize/$storagePool.TotalManagedSpace)*100)
}
AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolStorageOverProvisionPercentID"] -propertyValue $overProvisionPercent

$ProvisioningTypeDefault = ""
if ($storagePool.ProvisioningTypeDefault)
{
$ProvisioningTypeDefault = $storagePool.ProvisioningTypeDefault.ToString()
}

AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolProvisioningTypeDefaultPropertyID"] -propertyValue $ProvisioningTypeDefault

$SupportedProvisioningTypes = ""
foreach($type in $storagePool.SupportedProvisioningTypes)
{
$SupportedProvisioningTypes = $SupportedProvisioningTypes + $type + "; "
}
$SupportedProvisioningTypes = $SupportedProvisioningTypes.TrimEnd('; ')

AddProperty -classInstance $storagePoolObject -propertyName $arg["StoragePoolSupportedProvisioningTypesPropertyID"] -propertyValue $SupportedProvisioningTypes
AddProperty -classInstance $storagePoolObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $storagePool.Name
AddInstance -discoveryData $discoveryData -instance $storagePoolObject


# Create a duplicate Top Level Storage Pool Object (Hosted by MS)
# Workaround to roll up health from objects across healthservices(StoragePool &lt;- StoragePool.Spaces)
$storagePoolMSObject = CreateClassInstance -classType $arg["StoragePoolMSClassID"]
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSIDPropertyID"] -propertyValue $storagePool.ID.ToString()
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSDescriptionPropertyID"] -propertyValue $storagePool.Description
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSPrimordialPropertyID"] -propertyValue $storagePool.Primordial
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSTotalManagedSpacePropertyID"] -propertyValue $storagePool.TotalManagedSpace
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSStorageClassificationPropertyID"] -propertyValue $Classification
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSStorageOverProvisionPercentID"] -propertyValue $overProvisionPercent
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSProvisioningTypeDefaultPropertyID"] -propertyValue $ProvisioningTypeDefault
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["StoragePoolMSSupportedProvisioningTypesPropertyID"] -propertyValue $SupportedProvisioningTypes
AddProperty -classInstance $storagePoolMSObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $storagePool.Name
AddInstance -discoveryData $discoveryData -instance $storagePoolMSObject
$msg = $msg + "`n Storage Pool MS " + $storagePool.Name + " Provisioning Type = " + $SupportedProvisioningTypes ;

# Add containment relationship to Storage Pool MS Group

$relationshipToStoragePoolGroup = CreateRelationshipInstance -relationshipType $arg["StoragePoolGroupContainsStoragePoolMSClassID"]
$relationshipToStoragePoolGroup.Source = $storagePoolGroupObject
$relationshipToStoragePoolGroup.Target = $storagePoolMSObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationshipToStoragePoolGroup

#Add containment relationship between Storage Pool MS to Storage Pool
$relationshipToStoragePool = CreateRelationshipInstance -relationshipType $arg["StoragePoolMSContainsStoragePoolRelationID"]
$relationshipToStoragePool.Source = $storagePoolMSObject
$relationshipToStoragePool.Target = $storagePoolObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationshipToStoragePool
$count= $count +1;
}
$msg = $msg + "`n Storage Discovery: Discovered " + $count + " Storage Pools."
AddTraceMessage -msg $msg

# Add hosted storage logical units (LUNs)
$storageLUNs = @(Get-SCStorageLogicalUnit -VMMServer $server -All)
$count= 0;
foreach ($storageLUN in $storageLUNs)
{
# Create LUN object and hosting relationship
$storageLUNObject = CreateClassInstance -classType $arg["StorageLogicalUnitClassID"]
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageProviderIDPropertyID"] -propertyValue $storageLUN.StoragePool.StorageArray.StorageProvider.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"]
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageArrayIDPropertyID"] -propertyValue $storageLUN.StoragePool.StorageArray.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["StoragePoolIDPropertyID"] -propertyValue $storageLUN.StoragePool.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitIDPropertyID"] -propertyValue $storageLUN.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitDescriptionPropertyID"] -propertyValue $storageLUN.Description
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitBlockSizePropertyID"] -propertyValue $storageLUN.BlockSize
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitNumberOfBlocksPropertyID"] -propertyValue $storageLUN.NumberOfBlocks
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitThinlyProvisionedPropertyID"] -propertyValue $storageLUN.ThinlyProvisioned
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitPrimordialPropertyID"] -propertyValue $storageLUN.Primordial
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitTotalCapacityPropertyID"] -propertyValue $storageLUN.TotalCapacity
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitRemainingCapacityPropertyID"] -propertyValue $storageLUN.RemainingCapacity
$Classification = ""
if ($storageLUN.Classification -ne $null)
{
$Classification = $storageLUN.Classification.ToString()
}
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitStorageClassificationPropertyID"] -propertyValue $Classification

# Virtual Disk ID
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitVirtualDiskUniqueIDPropertyID"] -propertyValue $storageLUN.SMLunId.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $storageLUN.Name
AddInstance -discoveryData $discoveryData -instance $storageLUNObject
$count= $count+ 1;
}
$trace = "Storage Discovery: Discovered " + $count + " Storage LUNs."
AddTraceMessage -msg $trace

# Add VM Host Disks and relationships
$VMHostDisks = @(Get-SCStorageDisk -VMMServer $server)
foreach ($VMHostDisk in $VMHostDisks)
{
if ($VMHostDisk.VMHost -eq $null -or $VMHostDisk.VMHost.VirtualizationPlatform -ne "HyperV")
{
continue;
}
# Create VMHostDisk and hosting relationship
$VMHostDiskObject = CreateClassInstance -classType $arg["VMHostDiskClassID"]
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $VMHostDisk.VMHost.FullyQualifiedDomainName
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostIDPropertyID"] -propertyValue $VMHostDisk.VMHost.ID.ToString()
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskIDPropertyID"] -propertyValue $VMHostDisk.ID.ToString()
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskCapacityPropertyID"] -propertyValue $VMHostDisk.Capacity
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskIsClusteredPropertyID"] -propertyValue $VMHostDisk.IsClustered
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskIsSanAttachedPropertyID"] -propertyValue $VMHostDisk.IsSanAttached
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskIsPassThroughCapablePropertyID"] -propertyValue $VMHostDisk.IsPassThroughCapable
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskLocationPropertyID"] -propertyValue $VMHostDisk.Location
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskDiskIDPropertyID"] -propertyValue $VMHostDisk.DiskID.ToString()
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskSMLunIDPropertyID"] -propertyValue $VMHostDisk.SMLunId
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskAvailableCapacityPropertyID"] -propertyValue $VMHostDisk.AvailableCapacity
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $VMHostDisk.Name
AddInstance -discoveryData $discoveryData -instance $VMHostDiskObject
if ($VMHostDisk.StorageLogicalUnit -ne $null)
{
# Add conteinment relationship to LUNs
foreach ($storageLUN in $VMHostDisk.StorageLogicalUnit)
{
# Create LUN object and hosting relationship, but don't add it to discovery data, just object for relationship mapping
$storageLUNObject = CreateClassInstance -classType $arg["StorageLogicalUnitClassID"]
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageProviderIDPropertyID"] -propertyValue $storageLUN.StoragePool.StorageArray.StorageProvider.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"]
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageArrayIDPropertyID"] -propertyValue $storageLUN.StoragePool.StorageArray.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["StoragePoolIDPropertyID"] -propertyValue $storageLUN.StoragePool.ID.ToString()
AddProperty -classInstance $storageLUNObject -propertyName $arg["StorageLogicalUnitIDPropertyID"] -propertyValue $storageLUN.ID.ToString()

# Create relationship object
$relationship = CreateRelationshipInstance -relationshipType $arg["StorageLogicalUnitContainsVMHostDiskClassID"]
$relationship.Source = $storageLUNObject
$relationship.Target = $VMHostDiskObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationship
}
}
}
AddTraceMessage -msg "Storage Discovery: Got Storage Disks."
# Add reference relationship from Virtual Disk Drive to VM Host Disk
$VirtualDiskDrives = @(Get-SCVirtualDiskDrive -VMMServer $server -All | where {$_.PassThroughDisk -ne $null})
foreach ($VirtualDiskDrive in $VirtualDiskDrives)
{
if ($VirtualDiskDrive.PassThroughDisk -ne $null -and $VirtualDiskDrive.PassThroughDisk.VMHost.VirtualizationPlatform -eq "HyperV")
{
# Create VMHostDisk and hosting relationship
$VMHostDiskObject = CreateClassInstance -classType $arg["VMHostDiskClassID"]
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $VirtualDiskDrive.PassThroughDisk.VMHost.FullyQualifiedDomainName
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostIDPropertyID"] -propertyValue $VirtualDiskDrive.PassThroughDisk.VMHost.ID.ToString()
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskIDPropertyID"] -propertyValue $VirtualDiskDrive.PassThroughDisk.ID.ToString()

# Create VirtualDiskDrive object
$VDDObject = CreateClassInstance -classType $arg["VDDClassID"]
AddProperty -classInstance $VDDObject -propertyName $arg["VDDIDPropertyID"] -propertyValue $VirtualDiskDrive.ID.ToString()

# Create relationship object
$relationship = CreateRelationshipInstance -relationshipType $arg["VirtualDiskDriveReferencesVMHostDiskClassID"]
$relationship.Source = $VDDObject
$relationship.Target = $VMHostDiskObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationship
}
}


# Add Virtual Hard Disk objects
$VirtualHardDisks = @(Get-VirtualHardDisk -VMMServer $server -All)
foreach ($VirtualHardDisk in $VirtualHardDisks)
{
# Create VirtualHardDisk
$VHDObject = CreateClassInstance -classType $arg["VHDClassID"]
AddProperty -classInstance $VHDObject -propertyName $arg["VHDIDPropertyID"] -propertyValue $VirtualHardDisk.ID.ToString()
AddProperty -classInstance $VHDObject -propertyName $arg["VHDDescriptionPropertyID"] -propertyValue $VirtualHardDisk.Description
AddProperty -classInstance $VHDObject -propertyName $arg["VHDVHDTypePropertyID"] -propertyValue $VirtualHardDisk.VHDType.ToString()
AddProperty -classInstance $VHDObject -propertyName $arg["VHDVHDFormatTypePropertyID"] -propertyValue $VirtualHardDisk.VHDFormatType.ToString()
AddProperty -classInstance $VHDObject -propertyName $arg["VHDVirtualizationPlatformPropertyID"] -propertyValue $VirtualHardDisk.VirtualizationPlatform.ToString()
AddProperty -classInstance $VHDObject -propertyName $arg["VHDMaximumSizePropertyID"] -propertyValue $VirtualHardDisk.MaximumSize
AddProperty -classInstance $VHDObject -propertyName $arg["VHDLocationPropertyID"] -propertyValue $VirtualHardDisk.Location
AddProperty -classInstance $VHDObject -propertyName $arg["VHDCurrentSizePropertyID"] -propertyValue $VirtualHardDisk.Size
AddProperty -classInstance $VHDObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $VirtualHardDisk.Name
AddInstance -discoveryData $discoveryData -instance $VHDObject
}

# Add reference relationship from Virtual Disk Drive to Virtual Hard Disk
$VirtualDiskDrives = @(Get-SCVirtualDiskDrive -VMMServer $server -All | where {$_.VirtualHardDisk -ne $null})
foreach ($VirtualDiskDrive in $VirtualDiskDrives)
{
# Create VirtualDiskDrive object
$VDDObject = CreateClassInstance -classType $arg["VDDClassID"]
AddProperty -classInstance $VDDObject -propertyName $arg["VDDIDPropertyID"] -propertyValue $VirtualDiskDrive.ID.ToString()

# Create VirtualHardDisk object
$VHDObject = CreateClassInstance -classType $arg["VHDClassID"]
AddProperty -classInstance $VHDObject -propertyName $arg["VHDIDPropertyID"] -propertyValue $VirtualDiskDrive.VirtualHardDisk.ID.ToString()

# Create relationship object
$relationship = CreateRelationshipInstance -relationshipType $arg["VirtualDiskDriveReferencesVHDClassID"]
$relationship.Source = $VDDObject
$relationship.Target = $VHDObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationship
}

# Add Host Volume and Host Volume relationships
$HostVolumes = @(Get-SCStorageVolume -VMMServer $server)
$VirtualHardDisks = @(Get-SCVirtualHardDisk -VMMServer $server -All)
foreach ($HostVolume in $HostVolumes)
{
if ($HostVolume.VMHost -eq $null -or $HostVolume.VMHost.VirtualizationPlatform -ne "HyperV")
{
continue;
}
# Create HostVolume and hosting relationship
$HostVolumeObject = CreateClassInstance -classType $arg["HostVolumeClassID"]
AddProperty -classInstance $HostVolumeObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $HostVolume.VMHost.FullyQualifiedDomainName
AddProperty -classInstance $HostVolumeObject -propertyName $arg["VMHostIDPropertyID"] -propertyValue $HostVolume.VMHost.ID.ToString()
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeIDPropertyID"] -propertyValue $HostVolume.ID.ToString()

$MountPoints = ""
foreach($MountPoint in $HostVolume.MountPoints)
{
$MountPoints = $MountPoints + $MountPoint + "; "
}

AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeMountPointsPropertyID"] -propertyValue $MountPoints
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeCapacityPropertyID"] -propertyValue $HostVolume.Capacity
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeVolumeLabelPropertyID"] -propertyValue $HostVolume.VolumeLabel
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeIsClusteredPropertyID"] -propertyValue $HostVolume.IsClustere
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeIsClusterSharedVolumePropertyID"] -propertyValue $HostVolume.IsClusterSharedVolume
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeFreeSpacePropertyID"] -propertyValue $HostVolume.FreeSpace
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeIsAvailableForPlacementPropertyID"] -propertyValue $HostVolume.IsAvailableForPlacement
$Classification = ""
if ($HostVolume.Classification -ne $null)
{
$Classification = $HostVolume.Classification.ToString()
}
AddProperty -classInstance $HostVolumeObject -propertyName $arg["HostVolumeClassificationPropertyID"] -propertyValue $Classification
AddProperty -classInstance $HostVolumeObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $HostVolume.Name
AddInstance -discoveryData $discoveryData -instance $HostVolumeObject

# Add containment relationship to VM Host Disk
foreach ($VMHostDisk in $HostVolume.HostDisk)
{
# Create VM Host Disk object and hosting relationship, but don't add it to discovery data, just object for relationship mapping
$VMHostDiskObject = CreateClassInstance -classType $arg["VMHostDiskClassID"]
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $VMHostDisk.VMHost.FullyQualifiedDomainName
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostIDPropertyID"] -propertyValue $VMHostDisk.VMHost.ID.ToString()
AddProperty -classInstance $VMHostDiskObject -propertyName $arg["VMHostDiskIDPropertyID"] -propertyValue $VMHostDisk.ID.ToString()

# Create relationship object
$relationship = CreateRelationshipInstance -relationshipType $arg["VMHostDiskContainsHostVolumeClassID"]
$relationship.Source = $VMHostDiskObject
$relationship.Target = $HostVolumeObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationship
}

# Add reference relationship from VHD to Host Volume

foreach ($VirtualHardDisk in $VirtualHardDisks)
{
if ($VirtualHardDisk.HostVolumeId -eq $HostVolume.Id)
{
# Create VirtualHardDisk
$VHDObject = CreateClassInstance -classType $arg["VHDClassID"]
AddProperty -classInstance $VHDObject -propertyName $arg["VHDIDPropertyID"] -propertyValue $VirtualHardDisk.ID.ToString()

# Create relationship object
$relationship = CreateRelationshipInstance -relationshipType $arg["VHDReferencesHostVolumeClassID"]
$relationship.Source = $VHDObject
$relationship.Target = $HostVolumeObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationship
}
}
}
$StorageFileShares = @(Get-SCStorageFileShare -VMMServer $server -All)
$fileShareMap = @{};
foreach($FileShare in $StorageFileShares)
{
$FileShareObject = CreateClassInstance -classType $arg["FileShareClassID"]
AddProperty -classInstance $FileShareObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"] #VMMServer hosts FileShare
$HostAssociationNames = ""
foreach($hostAssociation in $FileShare.HostAssociations)
{
$HostAssociationNames = $HostAssociationNames + $hostAssociation.Name + ";"
}
AddProperty -classInstance $FileShareObject -propertyName $arg["HostAssociationsPropertyID"] -propertyValue $HostAssociationNames
$ClusterAssociationNames = ""
foreach($clusterAssociation in $FileShare.ClusterAssociations)
{
if (!$ClusterAssociationNames.Contains($clusterAssociation.Name))
{
$ClusterAssociationNames = $ClusterAssociationNames + $clusterAssociation.Name + ";"
}
}
AddProperty -classInstance $FileShareObject -propertyName $arg["ClusterAssociationsPropertyID"] -propertyValue $ClusterAssociationNames
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareIDPropertyID"] -propertyValue $FileShare.ID.ToString()
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareDescriptionPropertyID"] -propertyValue $FileShare.Description
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareIsAvailableForPlacementPropertyID"] -propertyValue $FileShare.IsAvailableForPlacement
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareIsManagedPropertyID"] -propertyValue $FileShare.IsManaged
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareStorageClassificationPropertyID"] -propertyValue $FileShare.StorageClassification.ToString()
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareSharePathPropertyID"] -propertyValue $FileShare.SharePath
if ($FileShare.StorageVolumeID -ne $null)
{
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareStorageVolumeIDPropertyID"] -propertyValue $FileShare.StorageVolumeID.ToString()
}
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareFreeSpacePropertyID"] -propertyValue $FileShare.FreeSpace
AddProperty -classInstance $FileShareObject -propertyName $arg["FileShareCapacityPropertyID"] -propertyValue $FileShare.Capacity
AddProperty -classInstance $FileShareObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $FileShare.Name
AddInstance -discoveryData $discoveryData -instance $FileShareObject

#Discover Top-Level FileShare object as workaround to roll up health from FileShareSMB to FileShare
$FileShareMSObject = CreateClassInstance -classType $arg["FileShareMSClassID"]
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSIDPropertyID"] -propertyValue $FileShare.ID.ToString()
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSDescriptionPropertyID"] -propertyValue $FileShare.Description
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSIsManagedPropertyID"] -propertyValue $FileShare.IsManaged
if ($FileShare.UniqueId -ne $null)
{
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSUniqueIDPropertyID"] -propertyValue $FileShare.UniqueId
}
if ($FileShare.StorageFileServer -ne $null -and $FileShare.StorageFileServer.StorageArray -ne $null)
{
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSClusterNamePropertyID"] -propertyValue $FileShare.StorageFileServer.StorageArray.SMName
}
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSVMMServerPropertyID"] -propertyValue $arg["ComputerName"]
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSStorageClassificationPropertyID"] -propertyValue $FileShare.StorageClassification.ToString()
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSSharePathPropertyID"] -propertyValue $FileShare.SharePath
if ($FileShare.StorageVolumeID -ne $null)
{
AddProperty -classInstance $FileShareMSObject -propertyName $arg["FileShareMSStorageVolumeIDPropertyID"] -propertyValue $FileShare.StorageVolumeID.ToString()
}
AddProperty -classInstance $FileShareMSObject -propertyName $arg["EntityDisplayNameKey"] -propertyValue $FileShare.Name
AddInstance -discoveryData $discoveryData -instance $FileShareMSObject
$fileShareMap.Add($FileShare.ID , $FileShareMSObject);

#Add containment relationship between FileShare MS to File Share (VMM)
$relationshipToFileShare = CreateRelationshipInstance -relationshipType $arg["FileShareMSContainsFileShareVMMRelationID"]
$relationshipToFileShare.Source = $FileShareMSObject
$relationshipToFileShare.Target = $FileShareObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationshipToFileShare
}
AddTraceMessage -msg "Storage Discovery: Got file shares. Done!"

$vms = (Get-SCVirtualMachine -All -VMMServer $server);
$msg = "Storage Discovery: FileShare contains VM relationship"
$relCount = 0;
foreach ($vm in $vms)
{
$vhds = $vm.VirtualHardDisks;
if ($vhds -ne $null)
{
foreach ($vhd in $vhds)
{
$share = $vhd.FileShare;
if ($share -ne $null -and $fileShareMap[$share.ID] -ne $null)
{
$VMObject = CreateClassInstance -classType $arg["VirtualMachineClassID"]
AddProperty -classInstance $VMObject -propertyName $arg["VirtualMachineIDPropertyID"] -propertyValue $vm.ID.ToString()
AddProperty -classInstance $VMObject -propertyName $arg["ComputerPrincipalNameKey"] -propertyValue $arg["ComputerName"] #VMMServer hosts VM
#Add containment relationship between FileShare MS to VM
$relationshipToFileShare = CreateRelationshipInstance -relationshipType $arg["FileShareMSContainsVirtualMachineRelationID"]
$relationshipToFileShare.Source = $fileShareMap[$share.ID]
$relationshipToFileShare.Target = $VMObject
AddRelationshipInstance -discoveryData $discoveryData -relationship $relationshipToFileShare
$relCount = $relCount + 1;
}
}
}
}

$msg = $msg + "Storage Discovery: Discovered " + $relCount + " FileShare Contains VM relationships";
AddTraceMessage -msg $msg

#File Server and its hosted objects
$StorageFileServers = @(Get-SCStorageFileServer -VMMServer $server -All)
$fileServerCount = 0
foreach ($fs in $StorageFileServers)
{
#Only WindowsClusteredScaleOut FileServers discovery is supported
if ([Int32]$fs.FileServerType -eq 2)
{
if ($fs.StorageNodes -ne $null -and $fs.StorageNodes.Length -gt 0)
{
AddTraceMessage -msg "Storage Discovery: Enumerating Cluster Scaleout File Server Nodes"



$nodeNames = "";
foreach ($nodeName in $fs.StorageNodes.Name)
{
$nodeNames = $nodeNames + $nodeName + ", "
}
$nodeNames = $nodeNames.TrimEnd(', ');

CreateStorageVolumeMSInstances -fileServer $fs

foreach ($node in $fs.StorageNodes)
{
if (!$node.StorageArray.FirmwareVersion.Contains("6.3"))
{
$errorMsg = "Storage Discovery: Skipping File Server Windows " + $node.Name + " discovery due to incompatible Array's Firmware version " + $node.StorageArray.FirmwareVersion
AddTraceMessage -msg $erorMsg
}
else
{
CreateFileServerInstances -node $node -nodeNames $nodeNames -fileServer $fs -storageArrayMap $storageArrayMap
$fileServerCount++;
}
}
}
}
else
{
AddTraceMessage -msg "Storage Discovery: Ignoring File Servers which are not Clustered Scaleout file servers"
}
}
if ($fileServerCount -gt 0)
{
$trace = "Storage Discovery: Discovered " + $fileServerCount + " File Servers"
AddTraceMessage -msg $trace
}

# Return discovery data. If there is no data, return empty data (i.e. delete object and reference)
$discoveryData
}
Finally
{
if ($error -ne $null -and $error.Count -gt 0)
{
if ($error[0].Exception -ne $null)
{
$evt.WriteEntry($error[0].Exception.ToString(), $errorevent, 108);
}
}

if ($global:blockTraceMsg -ne $null -and $global:blockTraceMsg.Length -lt 31839)
{
$evt.WriteEntry($global:blockTraceMsg, $infoevent, 108);
}
if ($server -ne $null)
{
$server.Disconnect();
}
}
};

$result = Invoke-Command -Session $session -ScriptBlock $scriptBlock -ArgumentList $scriptBlockArgs
if ($result -eq $null )
{
AddTraceMessage -msg "Storage Discovery: discovery script failed retreiving storage discovery objects from VMM."
}
else
{
$objects = 0; $relationships = 0;
if ($result.ClassInstances -ne $null)
{
foreach ($classInstance in $result.ClassInstances)
{
$discoveredObject = $momDiscoveryData.CreateClassInstance($classInstance.ClassType);
foreach ($propertyId in $classInstance.Properties.Keys)
{
if ($classInstance.Properties[$propertyId] -ne $null)
{
$error.Clear();
try
{
$discoveredObject.AddProperty($propertyId, $classInstance.Properties[$propertyId]);
}
finally
{
if ($error -ne $null -and $error.Count -gt 0)
{
$trace = $trace + [string] $error;
}
}
}
else
{
$trace = $trace + "`nMissing Value in Property Id: " + $propertyId;
}
}
$momDiscoveryData.AddInstance($discoveredObject); $objects += 1;
}
}
if ($result.RelationshipInstances -ne $null)
{
foreach ($relationship in $result.RelationshipInstances)
{
$relationshipObject = $momDiscoveryData.CreateRelationshipInstance($relationship.RelationshipType);

$sourceObject = $momDiscoveryData.CreateClassInstance($relationship.Source.ClassType);
foreach ($propertyId in $relationship.Source.Properties.Keys)
{
if ($relationship.Source.Properties[$propertyId] -ne $null)
{
try
{
$sourceObject.AddProperty($propertyId, $relationship.Source.Properties[$propertyId]);
}
finally
{
if ($error -ne $null -and $error.Count -gt 0)
{
$trace = $trace + [string] $error;
}
}
}
else
{
$trace = $trace + "`n Missing Value in Property Id: " + $propertyId;
}
}

$targetObject = $momDiscoveryData.CreateClassInstance($relationship.Target.ClassType);
foreach ($propertyId in $relationship.Target.Properties.Keys)
{
if ($relationship.Target.Properties[$propertyId] -ne $null)
{
try
{
$targetObject.AddProperty($propertyId, $relationship.Target.Properties[$propertyId]);
}
finally
{
if ($error -ne $null -and $error.Count -gt 0)
{
$trace = $trace + [string] $error;
}
}
}
else
{
$trace = $trace + "`n Missing Value in Property Id: " + $propertyId;

}
}

$relationshipObject.Source = $sourceObject;
$relationshipObject.Target = $targetObject;
$momDiscoveryData.AddInstance($relationshipObject); $relationships += 1;
}
}
$trace = $trace + "`n Objects Discovered = " + $objects;
$trace = $trace + "`n Relationships Discovered = " + $relationships;
AddTraceMessage -msg $trace
}
}
Finally
{
Remove-PSSession $session;
$momDiscoveryData
AddTraceMessage -msg "Storage Discovery: Complete !"
}
</Script></ScriptBody>
<Parameters>
<!-- Discovery data arguments -->
<Parameter>
<Name>ElementID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>TargetID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>ComputerName</Name>
<Value>$Config/ComputerName$</Value>
</Parameter>
<!-- Storage Provider -->
<Parameter>
<Name>StorageProviderClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StorageProvider']$</Value>
</Parameter>
<Parameter>
<Name>StorageProviderIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageProvider']/ID$</Value>
</Parameter>
<Parameter>
<Name>StorageProviderTypePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageProvider']/Type$</Value>
</Parameter>
<Parameter>
<Name>StorageProviderDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageProvider']/Description$</Value>
</Parameter>
<!-- Storage Array -->
<Parameter>
<Name>StorageArrayClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StorageArray']$</Value>
</Parameter>
<Parameter>
<Name>StorageArrayDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/Description$</Value>
</Parameter>
<Parameter>
<Name>StorageArrayFirmwareVersionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/FirmwareVersion$</Value>
</Parameter>
<Parameter>
<Name>StorageArrayManufacturePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/Manufacture$</Value>
</Parameter>
<Parameter>
<Name>StorageArrayIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/ID$</Value>
</Parameter>
<Parameter>
<Name>StorageArrayModelPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/Model$</Value>
</Parameter>
<Parameter>
<Name>StorageArraySerialNumberPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/SerialNumber$</Value>
</Parameter>
<Parameter>
<Name>StorageSubsystemUniqueIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/StorageSubsystemUniqueID$</Value>
</Parameter>
<Parameter>
<Name>StorageArrayClusterNamePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageArray']/ClusterName$</Value>
</Parameter>
<!-- Storage Pool-->
<Parameter>
<Name>StoragePoolClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool']$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/ID$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/Description$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolPrimordialPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/Primordial$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolTotalManagedSpacePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/TotalManagedSpace$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolProvisioningTypeDefaultPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/ProvisioningTypeDefault$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSupportedProvisioningTypesPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/SupportedProvisioningTypes$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolStorageClassificationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/StorageClassification$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolStorageOverProvisionPercentID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StoragePool']/OverProvisionPercent$</Value>
</Parameter>
<!-- Storage Volume-->
<Parameter>
<Name>StorageLogicalUnitClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StorageLogicalUnit']$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/ID$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/Description$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitBlockSizePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/BlockSize$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitNumberOfBlocksPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/NumberOfBlocks$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitThinlyProvisionedPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/ThinlyProvisioned$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitPrimordialPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/Primordial$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitTotalCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/TotalCapacity$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitRemainingCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/RemainingCapacity$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitStorageClassificationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/StorageClassification$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitVirtualDiskUniqueIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnit']/VirtualDiskUniqueID$</Value>
</Parameter>
<!-- VM Host Disk-->
<Parameter>
<Name>VMHostDiskClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.VMHostDisk']$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/ID$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/Capacity$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskIsClusteredPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/IsClustered$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskIsSanAttachedPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/IsSanAttached$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskIsPassThroughCapablePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/IsPassThroughCapable$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskDiskIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/DiskID$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskLocationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/Location$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskSMLunIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/SMLunID$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskAvailableCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDisk']/AvailableCapacity$</Value>
</Parameter>
<!-- Host volume-->
<Parameter>
<Name>HostVolumeClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.HostVolume']$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/ID$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeMountPointsPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/MountPoints$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/Capacity$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeVolumeLabelPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/VolumeLabel$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeIsClusteredPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/IsClustered$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeIsClusterSharedVolumePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/IsClusterSharedVolume$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeFreeSpacePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/FreeSpace$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeIsAvailableForPlacementPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/IsAvailableForPlacement$</Value>
</Parameter>
<Parameter>
<Name>HostVolumeClassificationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.HostVolume']/Classification$</Value>
</Parameter>
<!-- VHD class-->
<Parameter>
<Name>VHDClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']$</Value>
</Parameter>
<Parameter>
<Name>VHDIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/ID$</Value>
</Parameter>
<Parameter>
<Name>VHDDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/Description$</Value>
</Parameter>
<Parameter>
<Name>VHDVHDTypePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/VHDType$</Value>
</Parameter>
<Parameter>
<Name>VHDVHDFormatTypePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/VHDFormatType$</Value>
</Parameter>
<Parameter>
<Name>VHDVirtualizationPlatformPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/VirtualizationPlatform$</Value>
</Parameter>
<Parameter>
<Name>VHDMaximumSizePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/MaximumSize$</Value>
</Parameter>
<Parameter>
<Name>VHDLocationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/Location$</Value>
</Parameter>
<Parameter>
<Name>VHDCurrentSizePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHD']/CurrentSize$</Value>
</Parameter>
<!-- File Share-->
<Parameter>
<Name>FileShareClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare']$</Value>
</Parameter>
<Parameter>
<Name>FileShareIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/ID$</Value>
</Parameter>
<Parameter>
<Name>FileShareDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/Description$</Value>
</Parameter>
<Parameter>
<Name>FileShareIsAvailableForPlacementPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/IsAvailableForPlacement$</Value>
</Parameter>
<Parameter>
<Name>FileShareIsManagedPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/IsManaged$</Value>
</Parameter>
<Parameter>
<Name>HostAssociationsPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/HostAssociations$</Value>
</Parameter>
<Parameter>
<Name>ClusterAssociationsPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/ClusterAssociations$</Value>
</Parameter>
<Parameter>
<Name>FileShareStorageClassificationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/StorageClassification$</Value>
</Parameter>
<Parameter>
<Name>FileShareSharePathPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/SharePath$</Value>
</Parameter>
<Parameter>
<Name>FileShareStorageVolumeIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/StorageVolumeID$</Value>
</Parameter>
<Parameter>
<Name>FileShareFreeSpacePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/FreeSpace$</Value>
</Parameter>
<Parameter>
<Name>FileShareCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare']/Capacity$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSContainsVirtualMachineRelationID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShareMSContainsVirtualMachine']$</Value>
</Parameter>
<!-- Relationships classes and referenced ckases and properties IDs-->
<Parameter>
<Name>VirtualMachineClassID</Name>
<Value>$MPElement[Name='VMM2016Discovery!Microsoft.SystemCenter.VirtualMachineManager.2016.VirtualMachine']$</Value>
</Parameter>
<Parameter>
<Name>VirtualMachineIDPropertyID</Name>
<Value>$MPElement[Name='VMMLibrary!Microsoft.SystemCenter.VirtualMachineManager.VirtualMachine']/VMMId$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolGroupClassID</Name>
<Value>$MPElement[Name='VMM2016Discovery!Microsoft.SystemCenter.VirtualMachineManager.2016.StoragePoolGroup']$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolGroupContainsStoragePoolMSClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePoolGroupContainsStoragePoolMS']$</Value>
</Parameter>
<Parameter>
<Name>VMMServerPropertyID</Name>
<Value>$MPElement[Name='VMM2016Discovery!Microsoft.SystemCenter.VirtualMachineManager.2016.StoragePoolGroup']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>StorageLogicalUnitContainsVMHostDiskClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.StorageLogicalUnitContainsVMHostDisk']$</Value>
</Parameter>
<Parameter>
<Name>VMHostDiskContainsHostVolumeClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VMHostDiskContainsHostVolume']$</Value>
</Parameter>
<Parameter>
<Name>VMHostIDPropertyID</Name>
<Value>$MPElement[Name='VMMLibrary!Microsoft.SystemCenter.VirtualMachineManager.VMHost']/VMMId$</Value>
</Parameter>
<Parameter>
<Name>VDDClassID</Name>
<Value>$MPElement[Name='VMM2016Discovery!Microsoft.SystemCenter.VirtualMachineManager.2016.VirtualDiskDrive']$</Value>
</Parameter>
<Parameter>
<Name>VDDIDPropertyID</Name>
<Value>$MPElement[Name='VMMLibrary!Microsoft.SystemCenter.VirtualMachineManager.VirtualDiskDrive']/VMMId$</Value>
</Parameter>
<Parameter>
<Name>VirtualDiskDriveReferencesVHDClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VirtualDiskDriveReferencesVHD']$</Value>
</Parameter>
<Parameter>
<Name>VHDReferencesHostVolumeClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VHDReferencesHostVolume']$</Value>
</Parameter>
<Parameter>
<Name>VirtualDiskDriveReferencesVMHostDiskClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.VirtualDiskDriveReferencesVMHostDisk']$</Value>
</Parameter>
<Parameter>
<Name>ComputerPrincipalNameKey</Name>
<Value>$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>EntityDisplayNameKey</Name>
<Value>$MPElement[Name="System!System.Entity"]/DisplayName$</Value>
</Parameter>
<!---File Server properties-->
<Parameter>
<Name>FileServerClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileServer.Windows']$</Value>
</Parameter>
<Parameter>
<Name>FileServerIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/ID$</Value>
</Parameter>
<Parameter>
<Name>FileServerClusterNamePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/ClusterName$</Value>
</Parameter>
<Parameter>
<Name>FileServerVMMServerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>FileServerDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/Description$</Value>
</Parameter>
<Parameter>
<Name>FileServerTypePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/FileServerType$</Value>
</Parameter>
<Parameter>
<Name>FileServerStorageNodesPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/StorageNodes$</Value>
</Parameter>
<Parameter>
<Name>FileServerFreeSpacePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/FreeSpace$</Value>
</Parameter>
<Parameter>
<Name>FileServerCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/Capacity$</Value>
</Parameter>
<Parameter>
<Name>FileServerModelPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/Model$</Value>
</Parameter>
<Parameter>
<Name>FileServerManufacturerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/Manufacturer$</Value>
</Parameter>
<Parameter>
<Name>FileServerSerialNumberPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServer']/SerialNumber$</Value>
</Parameter>
<Parameter>
<Name>ArrayReferencesFileServerClassID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.ArrayReferencesFileServer']$</Value>
</Parameter>
<!---Enclosure properties-->
<Parameter>
<Name>EnclosureClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.Enclosure']$</Value>
</Parameter>
<Parameter>
<Name>EnclosureDeviceIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/DeviceID$</Value>
</Parameter>
<Parameter>
<Name>EnclosureUniqueIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/UniqueID$</Value>
</Parameter>
<Parameter>
<Name>EnclosureVMMServerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>EnclosureModelPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/Model$</Value>
</Parameter>
<Parameter>
<Name>EnclosureManufacturerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/Manufacturer$</Value>
</Parameter>
<Parameter>
<Name>EnclosureSerialNumberPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/SerialNumber$</Value>
</Parameter>
<Parameter>
<Name>EnclosureFirmwareVersionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/FirmwareVersion$</Value>
</Parameter>
<Parameter>
<Name>EnclosureNumberOfSlotsPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.Enclosure']/NumberOfSlots$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSContainsEnclosureRelationID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePoolMSContainsEnclosure']$</Value>
</Parameter>
<Parameter>
<Name>ArrayReferencesEnclosureID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.ArrayReferencesEnclosure']$</Value>
</Parameter>
<!---Storage Pool MS properties-->
<Parameter>
<Name>StoragePoolMSClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSIDPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/ID$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSDescriptionPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/Description$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSPrimordialPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/Primordial$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSTotalManagedSpacePropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/TotalManagedSpace$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSProvisioningTypeDefaultPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/ProvisioningTypeDefault$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSSupportedProvisioningTypesPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/SupportedProvisioningTypes$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSStorageClassificationPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/StorageClassification$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSStorageOverProvisionPercentID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.MS']/OverProvisionPercent$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSContainsStoragePoolRelationID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePoolMSContainsStoragePool']$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolMSContainsStoragePoolSpacesRelationID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePoolMSContainsStoragePoolSpaces']$</Value>
</Parameter>
<!---Storage Pool Spaces properties-->
<Parameter>
<Name>StoragePoolSpacesClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesUniqueIDPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/UniqueID$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesVMMServerPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesProvisioningTypeDefaultPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/ProvisioningTypeDefault$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesResiliencySettingNameDefaultPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/ResiliencySettingNameDefault$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesSupportsDeduplicationPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/SupportsDeduplication$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesIsClusteredPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/IsClustered$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesIsReadOnlyPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/IsReadOnly$</Value>
</Parameter>
<Parameter>
<Name>StoragePoolSpacesDescriptionPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.StoragePool.StorageSpaces']/Description$</Value>
</Parameter>
<!-- File Share MS properties -->
<Parameter>
<Name>FileShareMSClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSIDPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/ID$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSDescriptionPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/Description$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSSharePathPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/SharePath$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSStorageVolumeIDPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/StorageVolumeID$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSStorageClassificationPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/StorageClassification$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSIsManagedPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/IsManaged$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSClusterNamePropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/ClusterName$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSUniqueIDPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/UniqueID$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSVMMServerPropertyID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.MS']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSContainsFileShareVMMRelationID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShareMSContainsFileShareVMM']$</Value>
</Parameter>
<Parameter>
<Name>FileShareMSContainsFileShareBaseRelationID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShareMSContainsFileShareBase']$</Value>
</Parameter>
<!-- File Share SMB properties -->
<Parameter>
<Name>FileShareSMBClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileShare.SMB']$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/ID$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBDescriptionPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/Description$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBVMMServerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBShareNamePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/ShareName$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBSharePathPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/SharePath$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBStorageVolumeIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/StorageVolumeID$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBStorageFileServerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/StorageFileServer$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBFreeSpacePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/FreeSpace$</Value>
</Parameter>
<Parameter>
<Name>FileShareSMBCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileShare.Base']/Capacity$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSClassID</Name>
<Value>$MPElement[Name='Microsoft.SystemCenter.VirtualMachineManager.Storage.2016.FileServerStorageVolume.MS']$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/StorageVolumeID$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSUniqueIDPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/UniqueID$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSCapacityPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/Capacity$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSVolumeLabelPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/VolumeLabel$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSIsCSVPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/IsClusterSharedVolume$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSFreeSpacePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/FreeSpace$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSClassificationPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/Classification$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSClusterNamePropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/ClusterName$</Value>
</Parameter>
<Parameter>
<Name>StorageVolumeMSVMMServerPropertyID</Name>
<Value>$MPElement[Name='SL!Microsoft.SystemCenter.VirtualMachineManager.Storage.FileServerStorageVolume.MS']/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>domain</Name>
<Value>$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/Domain$</Value>
</Parameter>
<Parameter>
<Name>username</Name>
<Value>$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/UserName$</Value>
</Parameter>
<Parameter>
<Name>password</Name>
<Value>$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/Password$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>false</StrictErrorHandling>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="DiscoveryProbe">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>