Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count properties of an object

Tags:

powershell

I try to count the number of drives on certain VM's in a Cluster:

(Get-ClusterGroup -Cluster <Name> | 
    Where-Object {$_.GroupType –eq 'VirtualMachine'} | 
    Get-VM | 
    Measure-Object -Property Harddrives).Count

--> Returns 55, the count of VM's in the Cluster

Several VM's have more than one Harddrive, how can I retrieve the proper Count of Drives in a pipelined command?

like image 475
MMAX Avatar asked Oct 19 '25 21:10

MMAX


1 Answers

I had a problem that was closer to the original question. I had a custom PowerShell object that I needed to literally count how many properties were in it. I found this:

($Object | Get-Member -MemberType NoteProperty | Measure-Object).Count
like image 190
Slogmeister Extraordinaire Avatar answered Oct 21 '25 10:10

Slogmeister Extraordinaire