Measure content volume and summarize inventories by extension or folder.

Sheet: 02 of 25 | Platform: Windows 10/11 | Shell: PowerShell 7.x and Windows PowerShell 5.1 (unless marked otherwise) | Editorial review: November 24, 2026

PowerShell cheat sheet index

Examples use the MGU project root and illustrative staging, backup, and download paths. Replace them with existing, approved paths as needed. Unless explicitly marked as a continuation, examples are independent. Read commands before running them; commands that write or modify files can change existing data.

Quick commands

1. Count immediate files

(Get-ChildItem -LiteralPath 'C:\MGU' -File | Measure-Object).Count

2. Count all HTML files

(Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Filter '*.html' |
    Measure-Object).Count

3. Count directories

(Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -Directory |
    Measure-Object).Count

4. Count files by extension

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File |
    Group-Object Extension | Sort-Object Count -Descending |
    Select-Object Name, Count

5. Count HTML files by immediate parent folder

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Filter '*.html' |
    Group-Object DirectoryName | Select-Object Name, Count

6. Total bytes of HTML files

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Filter '*.html' |
    Measure-Object Length -Sum

Operational notes

Measure-Object returns zero for an empty count. Grouping by DirectoryName counts each file once in its immediate parent, not in all ancestors. Hidden or inaccessible files may be omitted.

Official documentation