Check expected items, naming conventions, empty files, and access failures.

Sheet: 17 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. Check expected site components

$expected = 'C:\MGU\component\lib.css', 'C:\MGU\component\header.html', 'C:\MGU\component\footer.html'
$expected | ForEach-Object { [pscustomobject]@{Path=$_; Exists=(Test-Path -LiteralPath $_ -PathType Leaf)} }

2. Identify empty HTML files

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Filter '*.html' |
    Where-Object { $_.Length -eq 0 } | Select-Object FullName

3. Find filenames that violate lowercase kebab-case policy

Get-ChildItem -LiteralPath 'C:\MGU\library' -Recurse -File -Filter '*.html' |
    Where-Object { $_.Name -cnotmatch '^[a-z0-9]+(?:-[a-z0-9]+)*\.html$' }

4. Find directories with no immediate children

Get-ChildItem -LiteralPath 'C:\MGU\library' -Recurse -Directory |
    Where-Object { -not (Get-ChildItem -LiteralPath $_.FullName -Force -ErrorAction Stop | Select-Object -First 1) }

5. Collect enumeration errors explicitly

$scanErrors = @()
$files = @(Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Force -ErrorAction SilentlyContinue -ErrorVariable +scanErrors)
$scanErrors | Select-Object Exception, TargetObject

6. Report scan scope and errors (run after prior command)

[pscustomobject]@{Files=$files.Count; EnumerationErrors=$scanErrors.Count}

Operational notes

An empty discrepancy list is meaningful only when the scan scope and error count are known. Naming policy exceptions may be intentional. Review symbolic links and junctions before large recursive scans.

Official documentation