VMware Cloud Community
billyjoel
Enthusiast
Enthusiast

CLI get volume information

Hi all,

I have the below script to get a report from some VMs and it works fine for me but I also need to get the VM volumes information, how can I achieve it within the same script?

$vms = Get-VM | Where-Object { $_.Name -like '*test*'};

foreach ($vm in $vms) {

    $vmname = $vm.name;

    $totalcores = [string]$vm.numcpu

    $corespersocket = [string]((get-view $vm).config.hardware.numcorespersocket);

    $sockets = [string]([int]($totalcores / $corespersocket));

    $memorygb = [string]$vm.memorygb;

    $ProvisionedSpace = [string]$vm.ProvisionedSpaceGB;

    $UsedSpace = [string]$vm.UsedSpaceGB;

    $out = $vmname + "," + $totalcores + "," + $sockets + "," + $corespersocket + "," + $memorygb + "," + $ProvisionedSpace + "," + $usedSpace;

    $out >> c:\users\hello\documents\test.csv;

}

I have tried unsuccessfully with get-harddisk.

Tags (3)
0 Kudos
2 Replies
scott28tt
VMware Employee
VMware Employee

Moderator: Moved to PowerCLI


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
LucD
Leadership
Leadership

What exactly do you mean by "volumes"?
Are that the datastores on which the VM lives, or the drives inside the Guest OS?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos