Virtual Machine VMDK file report with PowerCLI
I have created a simple report-script that gives a list of what kind of format and how many vmdk each VM has. The report tells me if the disks are Thin or Thick and what size they are i GB.
after some magic in Excel it looks like this 🙂
And the powerCLI script looks like this, it is quite simple but still gives me information that i need for all my VMs on all datastores and quickly i can tell which machines that uses a lot of disk on my precious SAN 😉
# Get data about vmdk and format # # Niklas Ã…kerlund / RTS $VMs = Get-VM * $Data = @() foreach ($VM in $VMs){ $VMDKs = $VM | get-HardDisk foreach ($VMDK in $VMDKs) { if ($VMDK -ne $null){ $CapacityGB = $VMDK.CapacityKB/1024/1024 $CapacityGB = [int]$CapacityGB $into = New-Object PSObject Add-Member -InputObject $into -MemberType NoteProperty -Name VMname $VM.Name Add-Member -InputObject $into -MemberType NoteProperty -Name Datastore $VMDK.FileName.Split(']')[0].TrimStart('[') Add-Member -InputObject $into -MemberType NoteProperty -Name VMDK $VMDK.FileName.Split(']')[1].TrimStart('[') Add-Member -InputObject $into -MemberType NoteProperty -Name StorageFormat $VMDK.StorageFormat Add-Member -InputObject $into -MemberType NoteProperty -Name CapacityGB $CapacityGB $Data += $into } } } $Data | Sort-Object VMname,Datastore,VMDK | Export-Csv -Path C:\temp\VM-VMDKs.csv -NoTypeInformation