VMware Cloud Community
jvm2016
Hot Shot
Hot Shot

disksinformation_powercli

Hi Luc,

if you can suggest how i can run orange line in background and not shown in console .as this can cause overwhelming display of vm partitions which is not desired .

all i want to display is green light .

also i found that freespacepercent is not the direct properties in most of the commands in datastore and disk partitions which i think should be incorporated in future release of powercli.

foreach($v in (get-vm -Location cluster1|?{$_.Guest.GuestFamily -eq 'windowsguest'}))

  {

  $vm=get-vm -name $v

  #$vm.guest.Disks

  #cls

  $paths=$vm.guest.Disks

 

  foreach($p in $paths)

  {

  $partition_freespace_percent=$p.freespacegb/$p.capacityGB*100

  $partition_freespace_percent_round=[math]::Round($partition_freespace_percent)

  #$partition_freespace_percent_round

  $p|select @{N='vmname';E={$vm.name}},@{N='partition';E={$p.Path}},@{N='freespacepercent';E={$partition_freespace_percent_round}}

  if($partition_freespace_percent_round -le 10)

  {

write-host "check free space percentage on" $p.path "on" $vm.name -ForegroundColor red

  }

  }}

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

If you don't want to show the output from that line on the console, where should it go then?
If nowhere, you could just remove the line.

I suspect you are mixing disk characteristics as seen by vSPhere and what the guest OS sees as partitions.
These are not the same!
You can have for example multiple guest OS partitions on one VMDK.
And the inverse is also possible, you can have a VMDK, which doesn't have any partitions in the guest OS.


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

ohhh yes you are right i can remove that line .

my intention is to get guest partitions and my understanding so far and what i have observed is vmdk and guest partition have one to one mapping and relationship.

so if i have vm with 2 vmdks ican have c: on first vmdk and 😧 drive on second vmdk  and so on..  i think this is the best practice and i have not seen anyone creating two partitions on same vmdk.

Reply
0 Kudos
LucD
Leadership
Leadership

That is indeed the best practice, but not universally in use.
A Windows guest OS, for example, creates a partition as well, not in use for the users of the guest OS.
In short, currently, there is no fool-proof method to link a VMDK with one or more guest partitions.
Even if you have a one-to-one mapping, it's impossible to say which VMDK corresponds with which guest OS partition.
Whatever method you might find on the Internet, I can produce you an example where the method will not work.

Sorry, no real solution available (at this point in time).


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

Reply
0 Kudos
jvm2016
Hot Shot
Hot Shot

I thought there might be some way of checking this but as yu mentioned no solution at this point of time so only option is to check through size of vmdk.however that causes confusion when two vmdk have same size.

Reply
0 Kudos
LucD
Leadership
Leadership

Indeed, and it can be even more confusing with specific guest OSs.
Note that Windows creates a small System partition, so comparing VMDK sizes  would already be a problem.


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

Reply
0 Kudos