Ever wonder how much storage is used by your thin provisioned luns? Well here is some power shell to find out:
Thin provisioned allocation
# Define Variables
$outputFile = 'C:\VMDiskCapacity.csv'
$myCol = @() # Prepare output collection
$VMs = Get-VM | sort Name # Get all VMs (sorted)
$counter = 0 # Initialize counter for progress bar
ForEach ($VM in $VMs) # Loop through VMs
{
$counter++ # Increase counter for progress bar
Write-Progress -Activity "Gathering disk information" -Status "Processing VM $VM" -PercentComplete (100*($counter/$VMs.count)) #
$myObj = "" |
select VM, TotalDiskSizeGB # Create output object
$myObj.VM = $VM.Name # Virtual Machine Name
$TotalDiskSizeKB = 0
ForEach ($DISK in $VM.HardDisks)
{
$TotalDiskSizeKB += $DISK.CapacityKB
}
$myObj.TotalDiskSizeGB = [math]::Round(($TotalDiskSizeKB * 1KB / 1GB),0) #Disk Size in GB
$myCol += $myObj # Add output to collection
}
$myCol | Export-Csv $outputFile -NoTypeInformation # Export output to csv