Check Provisioning Type of a Windows Server Volume

This post was originally published on this site

I had a question asked about how to determine whether or not a connected volume to a Windows Server host is thin provisioned or not. I put together the below PowerShell script to do the following:

  • Retrieve the locally connected volumes. Since this is using Get-WMIObject this is usable across all versions of Windows Server supported by Pure Storage.
  • Connect to the FlashArray and retrieve volumes.
  • Compare the UniqueId of the locally connected volumes to the FlashArray volume serial numbers.
  • Return the volume name which has the correlated serial number.

PowerShell:

# Get connected volumes to host
$UniqueIds = Get-WMIObject -Class MSFT_Disk -Namespace 'ROOTMicrosoftWindowsStorage' | Select-Object ProvisioningType,UniqueId,Number

# Connect to FlashArray
$FlashArray = New-PfaArray -EndPoint 10.21.201.57 -Credentials (Get-Credential) -IgnoreCertificateError

# Retrieved Volumes
$Volumes = Get-PfaVolumes -Array $FlashArray | Select-Object Name,Serial

# Inspect Volumes and compare to UniqueId
ForEach ($UniqueId in $UniqueIds) {
    ForEach ($Volume in $Volumes) {
        If (($UniqueId.UniqueId).Substring($UniqueId.UniqueId.Length-24) -eq $Volume.Serial) {
            Write-Host "Volume: $($Volume.Name)"
            Write-Host "Serial: $($Volume.serial)"
            Switch ($UniqueId.ProvisioningType) {
                0 { Write-Host "Type: Unknown" }
                1 { Write-Host "Type: Thin" }
                2 { Write-Host "Type: Fixed" }
            }
        }
    }
}

Example Output:

PS C:UsersAdministrator.MSLABDesktop> .Get-PfaVolumeType.ps1

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential

Volume: Server02-Data01
Serial: 45084F3508BF461400011CF9
Type: Thin

I will be adding this as a cmdlet to the PowerShell Toolkit.

Thanks,
Barkz