Stage and relocate files with explicit destinations and preview-first operations.

Sheet: 08 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. Preview copying one file

Copy-Item -LiteralPath 'C:\MGU\index.html' -Destination 'C:\MGU-Staging\index.html' -WhatIf

2. Copy a file to an existing backup directory

Copy-Item -LiteralPath 'C:\MGU\index.html' -Destination 'C:\MGU-Backup\' -ErrorAction Stop

3. Preview a directory copy

Copy-Item -LiteralPath 'C:\MGU\library' -Destination 'C:\MGU-Backup\' -Recurse -WhatIf

4. Preview moving one file

Move-Item -LiteralPath 'C:\MGU-Staging\article.html' -Destination 'C:\MGU\library\article.html' -WhatIf

5. Preview moving matching files to an existing folder

Get-ChildItem -LiteralPath 'C:\MGU-Staging' -File -Filter '*.html' |
    Move-Item -Destination 'C:\MGU\library\' -WhatIf

6. Verify a copied file by content hash

(Get-FileHash -LiteralPath 'C:\MGU\index.html').Hash -eq
    (Get-FileHash -LiteralPath 'C:\MGU-Backup\index.html').Hash

Operational notes

Create and verify destination folders first. Preview results and inspect collisions; copy operations may overwrite existing files. Do not flatten recursive trees unless duplicate names have been resolved. Remove -WhatIf only after review.

Official documentation