Initialize project folders and text files without inadvertently overwriting existing work.
Sheet: 11 of 25 | Platform: Windows 10/11 | Shell: PowerShell 7.x and Windows PowerShell 5.1 (unless marked otherwise) | Editorial review: November 24, 2026
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. Create a project folder
New-Item -Path 'C:\MGU-Staging' -ItemType Directory -Force
2. Create nested folders
New-Item -Path 'C:\MGU-Staging\library\reference' -ItemType Directory -Force
3. Create an empty file without -Force
New-Item -Path 'C:\MGU-Staging\notes.txt' -ItemType File -ErrorAction Stop
4. Create a file with initial content
New-Item -Path 'C:\MGU-Staging\README.txt' -ItemType File -Value 'Draft notes' -ErrorAction Stop
5. Append a line to a known UTF-8 text file
Add-Content -LiteralPath 'C:\MGU-Staging\notes.txt' -Value 'Review pending' -Encoding UTF8
6. Check that a directory exists
Test-Path -LiteralPath 'C:\MGU-Staging\library\reference' -PathType Container
Operational notes
-Force is suitable for ensuring an existing directory is available, but using it on New-Item -ItemType File may overwrite data. New-Item and Add-Content encoding behavior varies by version; use an explicit encoding strategy for production files.