2 Replies Latest reply on Jan 14, 2020 12:36 AM by LucD

    CLI get volume information

    billyjoel Lurker

      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.