skipping powershell using default property/Method having same header?

I have a data with Column header as count.
When I use $variable.count I get the total count of the list/array instead of the count values.

How do I skip/bypass powershell considering Count as the method.?

I am not posting the data since it is a simple question.

This is something I did in the past way ago… but not able to recollect it now :frowning:

Note that I do not want to use

select @{ expression={$_.Count}; label='Something else' }.....
I remember there is better way to list count data itself without changing the header name.

Use Select-Object.

$variable | Select-Object count

#or

$variable | Select-Object -ExpandProperty count

Its always better to not to have column header as same as property name. Count is a property and not a method. Since you $Variable is a collection , it has a property called count.

@KvPrasoon,
I understand. But there is a lot of situation where you have to deal with it.
For example, I am pulling an inventory of Devops Udeploy using RESTAPI’s.
And API result contains header named Count, Length, Rank…
OR
Importing CSV which has header Count and manipulating it.

And in response to your reply, I need to use this count inside ForEach($item in $item.count){}
Note that this count in $item.count is the header.

Now, I may not use select object inside for each…

With all that said. I know there was a easier method :slight_smile: something like $variable.‘Count’ or $variable.[count]… . which I am not able to recollect.

I think you are looking for Measure-Object:

PS C:\Users\Rob> $processes = Get-Process | Select Handles -First 10


PS C:\Users\Rob> $processes

Handles
-------
    589
   1097
    542
    540
    241
    225
    594
    483
    692
   1214



PS C:\Users\Rob> $processes | Measure-Object -Property Handles -Sum | Select -ExpandProperty Sum

6217

Thanks Rob for the response. But I am not looking for this. Ok Let me clarify.
Lets say I have below data in $temp
Count Product


2 Apple
3 Orange
4 Mango

Now $temp.count will give me output 3. $temp | Select Count will give me the values under header count

But I need this to be used inside foreach($item in $temp.count){}
It wont work since $temp.Count results to 3… … Hope this is clear…

You can still do this with foreach

 foreach($item in $temp | Select-Object -ExpandProperty count)

That works … … Times smaller things break your head :slight_smile: well I was since last 2 hours…
Thank you very much…

You can get to it through its enumerator… $temp.GetEnumerator().Count

$temp.GetEnumerator().Count :+1:

Perfect… this is what i was trying to recollect…