Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 230663

Re: How to get VirtualMachine storage info

$
0
0

Try something like this using powercli

 

$report = @()                                  
$allvms = Get-VM | Sort-Object $_.Name 

foreach ($vm in $allvms) {

$vmview = $vm | Get-View             
foreach($disk in $vmview.Storage.PerDatastoreUsage){
$dsview = (Get-View $disk.Datastore)           
$dsview.RefreshDatastoreStorageInfo()             
$vmview.Config.Name                       

 

$row = "" | select VMNAME, DATASTORE, VMSIZE_MB, VMUSED_MB, PERCENT
$row.VMNAME = $vmview.Config.Name                  
$row.DATASTORE = $dsview.Name
$row.VMSIZE_MB = (($disk.Committed+$disk.Uncommitted)/1024/1024)
$row.VMUSED_MB = (($disk.Committed)/1024/1024)
$row.PERCENT = [int](($row.VMUSED_MB / $row.VMSIZE_MB)*100)
$report += $row                                                        

   }

}

$report | Export-Csv "C:\vm_ds.csv" -NoTypeInformation

 

 

Regards,

Julien.


Viewing all articles
Browse latest Browse all 230663

Trending Articles