Powershell中Measure-Object可以对对象计数并计算数字值的最小值、最大值、总和及平均值。对于文本对象,它可以计数并计算行数、单词数和字符数。

以D:\为例来说明:

Powershell进行统计的功能_measure

 

(1)计算D中文件和文件夹的个数;

Get-ChildItem |Measure-Object

Powershell进行统计的功能_measure_02

(2)计算D中文件的大小的总和,最小,最大,平均数

Get-ChildItem |Measure-Object -Property length -Minimum -Maximum -Average -Sum

Powershell进行统计的功能_measure_03

(3)计算文件中的字符数,行数,单词数;

Get-Content D:\powershelllog.txt |Measure-Object -Character -Line –Word

Powershell进行统计的功能_object_04

 

参考网址:http://technet.microsoft.com/zh-CN/library/dd315251.aspx