Build repeatable, structured snapshots of a large website filesystem.

Sheet: 16 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. Capture a baseline inventory in memory

$root = 'C:\MGU'
$files = @(Get-ChildItem -LiteralPath $root -Recurse -File -Force -ErrorAction Stop)

2. Generate root-relative paths (run after baseline)

$prefix = $root.TrimEnd('\') + '\'
$files | Select-Object @{Name='RelativePath';Expression={$_.FullName.Substring($prefix.Length)}}, Length, LastWriteTimeUtc

3. Export a timestamped inventory (run after baseline)

$stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$files | Select-Object FullName, Extension, Length, CreationTimeUtc, LastWriteTimeUtc |
    Export-Csv -LiteralPath "C:\MGU-Staging\inventory-$stamp.csv" -NoTypeInformation -Encoding UTF8

4. Summarize counts by extension (run after baseline)

$files | Group-Object Extension | Select-Object Name, Count

5. Summarize total file bytes by parent folder (run after baseline)

$files | Group-Object DirectoryName | ForEach-Object {
    [pscustomobject]@{ Folder = $_.Name; Count = $_.Count; Bytes = ($_.Group | Measure-Object Length -Sum).Sum }
}

6. Generate SHA-256 hashes for selected files

Get-ChildItem -LiteralPath 'C:\MGU\library' -Recurse -File -Filter '*.html' |
    Get-FileHash -Algorithm SHA256

Operational notes

Keep inventory reports outside the scanned tree to avoid self-inclusion. Define the scan root, hidden-item policy and error policy. A filesystem can change during a scan; hashes and metadata are observations, not an atomic snapshot.

Official documentation