Measure-Object

 

Additional Resources for Measure-Object

 

Calculating Basic Statistics

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/measure-object.mspx

 

 

SYNOPSIS

Measures characteristics of objects and their properties.

 

SYNTAX

Measure-Object [[-property] <string[]>] [-inputObject <psobject>] [-average] [-sum] [-minimum] [-maximum] [<CommonParameters>]

 

Measure-Object [[-property] <string[]>] [-inputObject <psobject>] [-line] [-word] [-character] [-ignoreWhiteSpace]

[<CommonParameters>]

 

DETAILED DESCRIPTION

Measures characteristics of objects and their properties. The Measure-Object cmdlet supports measurement of any type of object and specialized measurements of objects with textual properties. There are three distinct actions that the cmdlet can perform. The type of measurement action that takes place depends upon the parameters specified.

 

If you do not specify any parameters, the cmdlet returns a count of the number of input objects.

 

If the Property parameter is specified along with either the Sum or Average parameter, the sum or average of the properties is calculated.

 

Textual properties are measured when one or more of the  Line, Word, or Character, parameters is specified.

 

PARAMETERS

 

-inputObject <psobject>

Specifies the objects to be measured. Enter a variable that contains the objects or type a command or expression that gets the objects.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

true (ByValue)

Accept wildcard characters? 

false

 

-property <string[]>

Specifies the properties to measure.

 

Required?

false

Position?

1

Default value

N/A - When this parameter is used the property(s) must be specified

Accept pipeline input?  

false

Accept wildcard characters? 

true

 

-average <SwitchParameter>

Averages the values in the designated property.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-line <SwitchParameter>

Counts the number of lines in the input object.

                                                            

Required?

false

Position?

named

Default value

False

Accept pipeline input?   

false

Accept wildcard characters? 

false

 

-sum <SwitchParameter>

Sums the values of the properties.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-minimum <SwitchParameter>

Determines the minimum value of the properties.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-maximum <SwitchParameter>

Determines the maximum value of the properties.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-word <SwitchParameter>

Counts the number of words in the input object.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-character <SwitchParameter>

Counts the number of characters in the input object.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-ignoreWhiteSpace <SwitchParameter>

Ignores white space in word counts and character counts. By default, white space is not ignored.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUT TYPE

Any Pipeline object(s).

 

RETURN TYPE

A GenericMeasureInfo or TextMeasureInfoObject.

 

EXAMPLE 1

 

get-childitem | measure-object

 

This command displays the number of files and folders in the current directory. (Requires that the current location is a drive mapped to the FileSystem provider)

 

EXAMPLE 2

 

get-childitem | measure-object -property length -minimum -maximum -average

 

This command displays the minimum, maximum and sum of the sizes of all files in the current directory as well as the average size of a file in the directory.

 

EXAMPLE 3

 

get-content C:\test.txt | measure-object -character -line -word

 

This command displays the number of characters, words and lines in the text.txt file.

 

RELATED LINKS

Compare-Object

ForEach-Object

Group-Object

New-Object

Select-Object

Sort-Object

Tee-Object

Where-Object