I am still a newbie with this. . .is there a command (or pipeline) I can use to list my VMs and the size of the associated disk files?
Thanks,
Jeff
That info is available.
The simplest method is like this:
Get-VM | Get-Harddisk
If you need specific info you can pipe the output to for example the Select-Object cmdlet.
Or if you want only specific entries you can filter the output with Where-Object cmdlet.
The possibilities are endless with PowerShell.
As an example, the following line list the name of the guest, the name of the hard disk and the size of the hard disk in KB
Get-VM | %{$_ | Tee-Object -variable vm | Get-HardDisk | %{Write-Host $vm.Name $_.Name $_.CapacityKB}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That info is available.
The simplest method is like this:
Get-VM | Get-Harddisk
If you need specific info you can pipe the output to for example the Select-Object cmdlet.
Or if you want only specific entries you can filter the output with Where-Object cmdlet.
The possibilities are endless with PowerShell.
As an example, the following line list the name of the guest, the name of the hard disk and the size of the hard disk in KB
Get-VM | %{$_ | Tee-Object -variable vm | Get-HardDisk | %{Write-Host $vm.Name $_.Name $_.CapacityKB}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm not sure yet where the disconnect is, but your second (fancy) way to get the disk sizes is not correctly parsed for some of my VMs. For example, I have a VM with three vmdks, two are on one lun and the third is on a seperate lun.The second listing shows the correct values for the second and third disk (2.5GB and 329GB).
Get-VM | %{$_ | Tee-Object -variable vm | Get-HardDisk | %{Write-Host $vm.Name $_.Name $_.CapacityKB}}
mrs1 Hard Disk 1 8388608
mrs1 Hard Disk 2 4718592
mrs1 Hard Disk 3 16777216
Get-VM | Get-HardDisk | select capacityKB,filename
Previous to working with powershell (as I am a PS n00b), we were just running du on a host, pointing at the vmfs areas
du -sh /vmfs/volumes/DATASTORE/
LucD, if you have any ideas as to why the wacky numbers I would love to hear it.
---
datastore names have been altered to proctect the innocent.