Measure-Object


Measures various aspects of objects or their properties.

Snap-In: Microsoft.PowerShell.Utility

Syntax:

Measure-Object [

 [-Property] <String[]>] [-InputObject <PSObject>] [-Sum] [-Average] [-Maximum] [-Minimum] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>] 

Measure-Object [

 [-Property] <String[]>] [-InputObject <PSObject>] [-Line] [-Word] [-Character] [-IgnoreWhiteSpace] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-ErrorVariable <String>] [-OutVariable <String>] [-OutBuffer <Int32>] 

Description:

There are four basic modes that are used with the measure-object Cmdlet.

  1. Default mode. No input parameters are specified. Performs a count of the number input objects. For example, get-childitem c:/smp | measure-object. This line returns the count of objects received from the get-childitem cmdlet. Be aware that there will be one object for each file and one object for each folder.

  2. Specify the ?Property parameter with one or more of the specified sum or average parameters. In this case, the action determined by the sum and average parameters. For example, get-childitem c:/smp | measure-object ? Property Length - Average This sample line finds the average size of files in the folder C:/smp. The count contains the number of total number of objects.

  3. Group by property(s) before performing the measure operations. For example, get-childitem c:/smp | measure-object ?Groupby Length. This sample command line counts the number of like sized groups. For example, all the files with equal lengths will be one group. In this example the count indicates how many groups there are.

  4. Count text. For example, Get-content smp.txt | measure-object ?Words. This line counts the words in the file smp.txt using the default culture setting. Be aware that you can also count the text within properties. For example: Get-childitem | measure-object ?Words ` ?Property CreationTime.DayOfWeek.



Windows PowerShell. TFM
Internet Forensics
ISBN: 982131445
EAN: 2147483647
Year: 2004
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net