PowerShell: Measure-Object Cmdlet

PowerShell: Measure-Object Cmdlet

The Measure-Object cmdlet is used to calculate the property values of certain object types. The cmdlet performs three types of measurements – object counts, descriptive statistical metrics of numeric values, and character counts.

?Example: Measure directory size

?Measure-Object -Property length -Minimum -Maximum -Sum -Average

?Use Case:

The client has an application cache folder that grows significantly and consumes storage space.

?Impact:

-????????? Performance impact: slower disk I/O, longer file access times

-????????? Storage impact: reduced available space for critical applications and data, potential disk fragmentation.

?Solution:

Implemented auto-cleanup using a scheduled script to delete the cache folder at a set file size limit using the Measure-Object cmdlet.

?In this post, I will share a version of the simple script used for auto-cleanup.

cache-cleanup.ps1

Further Reading: Measure-Object (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn

要查看或添加评论,请登录

Dee Ajibola-Crane, MBA, ACIM, CSM的更多文章

  • Safe Senders: Implementation

    Safe Senders: Implementation

    I am sure IT and non-IT folks alike have all heard about phishing, SPAM, junk, and malicious emails – as some of the…

  • Inline Credential Management in PowerShell Scripting

    Inline Credential Management in PowerShell Scripting

    PowerShell is undoubtedly a powerful tool for IT administrators – with benefits that include: 1. Flexibility and…

    2 条评论
  • PowerShell: Where-Object Cmdlet

    PowerShell: Where-Object Cmdlet

    A few weeks ago, as I sat at my home-office desk drinking from my cup of coffee (okay… I don’t drink coffee) and…

社区洞察

其他会员也浏览了