โšกPowerShellWiki
โ† All cheat sheets
๐Ÿ“

File System

Navigate, read, and manage files and directories.

Listing files and folders

List items in a directory

Show files and folders in the current location.

Get-ChildItem

List recursively

Include everything in subfolders too.

Get-ChildItem -Path C:\Projects -Recurse

Filter by extension

Only return files matching a pattern.

Get-ChildItem -Path . -Filter *.log -Recurse

Only files (no directories)

Exclude folders from the results.

Get-ChildItem -File

Creating and removing

Create a new folder

Make a directory (parents created as needed).

New-Item -Path ".\reports\2026" -ItemType Directory -Force

Create an empty file

Make a new empty file.

New-Item -Path ".\notes.txt" -ItemType File

Delete a file or folder

Remove an item; -Recurse for non-empty folders.

Remove-Item -Path ".\temp" -Recurse -Force

Copy, move, rename

Copy a file

Copy a file to another location.

Copy-Item -Path ".\report.docx" -Destination "D:\Backup\"

Move a file

Move (or cut) a file to another folder.

Move-Item -Path ".\report.docx" -Destination "D:\Archive\"

Rename a file

Change a file or folder name.

Rename-Item -Path ".\old.txt" -NewName "new.txt"

Bulk rename with a prefix

Add a date prefix to every .txt file in a folder.

Get-ChildItem -Filter *.txt | Rename-Item -NewName { "2026-07-27_" + $_.Name }

Reading and writing content

Read a whole file

Get the full contents of a text file.

Get-Content -Path ".\log.txt" -Raw

Read the last N lines

Tail the end of a file.

Get-Content -Path ".\log.txt" -Tail 20

Write text to a file

Overwrite a file with new content.

Set-Content -Path ".\out.txt" -Value "Hello world"

Append text to a file

Add a line without overwriting.

Add-Content -Path ".\log.txt" -Value "New entry"

Related cheat sheets