View Storage Spaces Direct (S2D) slabs placement statistics

Recently, I was dealing with an HCI cluster and I needed to see how the slabs (or extents, if you prefer) are placed on each disk. Since there is no such direct PowerShell command to visualize this information, I ended up writing a small function that serves this purpose. The function performs some queries on the virtual disk to find the slubs, calculate the statistics and correlate with the hosts that hold each disk. In the end, it groups the results and returns them in a single table.

I use only Get commands, so apart from a slight stress in the storage I/O you should not expect any issues. However, as always, be aware that I hold no responsibility on any problems caused by this code and you should always use it at your own risk.

I hope you enjoy it! If you do, please feel free to share your thoughts leaving a comment. I would also love to read any improvements.

Function GetCTL-VirtualDiskSlabs {
    View physical disks and virtual disks' extents (aka slabs) correlation.
	Created by Lefteris Mourikis (Nov 2019)

    Param (


    Begin {
        # Start of the BEGIN block.
		#$CtlVirtualDisk = $(Get-VirtualDisk -FriendlyName $VirtualDiskName | select *)
		$CtlPhysicalExtents = $(Get-VirtualDisk -FriendlyName $VirtualDiskName | Get-PhysicalExtent | select *)
		##$CtlPysicalExtentsCount = $($CtlPhysicalExtents | Measure).Count

		$CtlResultTmp = $CtlPhysicalExtents.PhysicalDiskUniqueId | Get-PhysicalDisk | `
			select @{Name="DiskUniqueID";Expression={$_.UniqueID}}, @{Name="DiskSerialNumber";Expression={$_.SerialNumber}}, `
			OperationalStatus, HealthStatus, Usage, `
			@{Name="HostName";Expression={$(Get-StorageNode -PhysicalDisk $(Get-PhysicalDisk -UniqueId $_.UniqueId) -PhysicallyConnected)[0].Name}}

		$CtlResult = $CtlResultTmp | select *, @{Name="ExtentsCount";Expression={$($CtlResultTmp | ? DiskUniqueID -eq $_.DiskUniqueID | Measure).Count}} `
			| Sort-Object -Property DiskUniqueID -Unique | Sort-Object -Property HostName
    } # End Begin block

    Process {
        # Start of PROCESS block.

    } # End of PROCESS block.

    End {
        # Start of END block.
		$CtlResult | ft *
        ##Write-Host "Total number of slabs: $CtlPysicalExtentsCount"
    } # End of the END Block.
} # End Function

Leave a Reply

Your email address will not be published.

Follow Me