Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text. (Measure-Object)

   

# NAME
Measure-Object

# SYNOPSIS
Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text.

# SYNTAX
Measure-Object [-Average] [-Maximum] [-Minimum] [-Sum] [[-Property] <string[]>] [-InputObject <psobject>] [<CommonParameters>]

Measure-Object [-Character] [-IgnoreWhiteSpace] [-Line] [-Word] [[-Property] <string[]>] [-InputObject <psobject>] [<CommonParameters>]

# DESCRIPTION
The Measure-Object cmdlet calculates the property values of certain types of object. Measure-Object performs three types of measurements, depending on the parameters in the command.
The Measure-Object cmdlet performs calculations on the property values of objects. It can count objects and calculate the minimum, maximum, sum, and average of the numeric values. For text objects, it can count and calculate the number of lines, words, and characters.

# PARAMETERS
-Average [<SwitchParameter>]
Displays the average value of the specified properties.

Required? false
Position? named
Default value
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
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
Accept pipeline input? false
Accept wildcard characters? false

-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

-Line [<SwitchParameter>]
Counts the number of lines in the input object.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Maximum [<SwitchParameter>]
Displays the maximum value of the specified properties.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Minimum [<SwitchParameter>]
Displays the minimum value of the specified properties.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Property <string[]>
Specifies one or more numeric properties to measure. The default is the Count (Length) property of the object.

Required? false
Position? 1
Default value Count
Accept pipeline input? false
Accept wildcard characters? false

-Sum [<SwitchParameter>]
Displays the sum of the values of the specified properties.

Required? false
Position? named
Default value
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
Accept pipeline input? false
Accept wildcard characters? false

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

# INPUTS
System.Management.Automation.PSObject
You can pipe objects to Measure-Object.

# OUTPUTS
GenericMeasureInfo or TextMeasureInfoObject

# NOTES

# EXAMPLE 1

C:\PS>get-childitem | measure-object

# Description
-----------
This command counts the files and folders in the current directory.

# EXAMPLE 2

C:\PS>get-childitem | measure-object -property length -minimum -maximum -average

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

# EXAMPLE 3

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

# Description
-----------
This command displays the number of characters, words, and lines in the Text.txt file.

# EXAMPLE 4

C:\PS>get-process | measure-object -property workingset -minimum -maximum -average

# Description
-----------
This command displays the minimum, maximum, and average sizes of the working sets of the processes on the computer.

# EXAMPLE 5

C:\PS>import-csv d:\test\serviceyrs.csv | measure-object -property years -minimum -maximum -average

# Description
-----------
This command calculates the average years of service of the employees of a company.

The ServiceYrs.csv file is a CSV file that contains the employee number and years of service of each employee. The first row in the table is a header row of "EmpNo, Years".

When you use Import-Csv to import the file, the result is a PSCustomObject with note properties of EmpNo and Years. You can use Measure-Object to calculate the values of these properties, just like any other property of an object.

# EXAMPLE 6

C:\PS>get-childitem | measure-object -property psiscontainer -max -sum -min -average

Count : 126
Average : 0.0634920634920635
Sum : 8
Maximum : 1
Minimum : 0
Property : PSIsContainer

# Description
-----------
This example demonstrates the Measure-Object can measure Boolean values. In this case, it uses the PSIsContainer Boolean property to measure the incidence of folders (vs. files) in the current directory.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113349
Compare-Object
ForEach-Object
Group-Object
New-Object
Select-Object
Sort-Object
Tee-Object
Where-Object

C:\Windows>powershell get-help New-Alias -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole









... Windows-10




Windows 10 How To

... Windows 10 FAQ
... Windows 10 How To




PowerShell: Calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text.

HTTP: ... PS_Windows/en/Measure-Object.htm
0.187
18698

Can I turn off the Aero in Windows 7 to 100 , not turn off it?

 /

Where can I download the free Avira AntiVir Personal?

 /

Sollte man die Daten Sicher Löschen auf Windows?

 /

T-Online Browser 7 Favoriten einblenden, aber wie?

 /

Modify the paging file pagefile.sys in Windows 8.1 and 10!

 /

Wordpad appears in the taskbar but the window is not visible!

 /

Start the Aero Desktop Clock with Windows, but how?

 /

Zoom and Dark Theme Visually Impaired and Eye Friendly!

 /

Let the program terminate correctly via parameters!

 /

Change settings in Win 8.1/8 when to be notified about customizes on your computer!

 /

How to change keyboard speed, Windows 10 / 11 typing speed is slow?

 /

Why for Windows, this simple digital clock on the desktop?

 /