Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6628857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:10:38+00:00 2026-05-25T22:10:38+00:00

Why does $a = GPS AcroRd32 | Measure $a.Count work, when GPS AcroRd32 |

  • 0

Why does

$a = GPS AcroRd32 | Measure
$a.Count

work, when

GPS AcroRd32 | Measure -Property Count

doesn’t?

The first example returns a value of 2, which is what I want, an integer.

The second example returns this:

Measure-Object : Property "Count" cannot be found in any object(s) input.
At line:1 char:23
+ GPS AcroRd32 | Measure <<<<  -Property Count
    + CategoryInfo          : InvalidArgument: (:) [Measure-Object], PSArgumentException
    + FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand


This Scripting Guy entry is where I learned how to use the “Count” Property in the first code sample.

The second code sample is really confusing. In this Script Center reference, the following statement works:

Import-Csv c:\scripts\test.txt | Measure-Object score -ave -max -min

It still works even if it’s re-written like so:

Import-Csv c:\scripts\test.txt | Measure-Object -ave -max -min -property score

I don’t have too many problems with accepting this until I consider the Measure-Object help page. The parameter definition for -Property <string[]> states:

The default is the Count (Length) property of the object.

If Count is the default, then shouldn’t an explicit pass of Count work?

GPS AcroRd32 | Measure -Property Count # Fails

The following provides me the information I need, except it doesn’t provide me with an integer to perform operations on, as you’ll see:

PS C:\Users\Me> $a = GPS AcroRd32 | Measure
PS C:\Users\Me> $a

Count    : 2
Average  :
Sum      :
Maximum  :
Minimum  :
Property :

PS C:\Users\Me> $a -is [int]
False


So, why does Dot Notation ($a.count) work, but not an explicitly written statement (GPS | Measure -Property Count)?

If I’m supposed to use Dot Notation, then I will, but I’d like to take this opportunity to learn more about how and *why PowerShell works this way, rather than just building a perfunctory understanding of PowerShell’s syntax. To put it another way, I want to avoid turning into a Cargo Cult Programmer/ Code Monkey.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:10:39+00:00Added an answer on May 25, 2026 at 10:10 pm

    One thing you need to know is that in PowerShell generally, and particulary in CmdLets you manipulate objects or collection of objects.

    Example: if only one ‘AcroRd32’ is running Get-Process will return a [System.Diagnostics.Process], if more than one are running it will return a collection of [System.Diagnostics.Process].

    In the second case you can write:

    (GPS AcroRd32).count
    

    Because a collection has a count property. The duality object collection is also valid in CmdLets parameters that most of the time supports objects or list of objects (collection built with the operator ,).

    PS C:\> (gps AcroRd32) -is [object[]]
    True
    

    Just use the Get-Member cmdlet:

    PS C:\> (gps AcroRd32) | Get-Member
    
       TypeName: System.Diagnostics.Process
    
    Name                       MemberType     Definition
    ----                       ----------     ----------
    Handles                    AliasProperty  Handles = Handlecount
    ...                        ...
    

    And

    PS C:\>  Get-Member -InputObject (gps AcroRd32)
    
       TypeName: System.Object[]
    
    Name           MemberType    Definition
    ----           ----------    ----------
    Count          AliasProperty Count = Length
    ...            ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does LocationManager have the ability to change, from example, from GPS to a more
I want to make application that will use GPS, as we know at first
Does Admob ask for location data via the GPS? If my app doesn't need
How to simulate my position in my app like GPS does? I want to
Does anyone know between GPS, compass heading and accelerometer which uses the most amount
Does anyone know how to turn off iPhone's GPS programmatically? Once I use the
Does anyone know how to get IntelliSense to work reliably when working in C/C++
Does anyone know how to transform a enum value to a human readable value?
Does anyone have a recommendation for a work flow for georeferencing high resolution aerial
I want to add full GPS support into my application. The .Net 4.0 System.Device.Location

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.