Command library / Get-Content
Get-Content
Print a file's contents as objects
PowerShell's file reader — the same job bash's cat and cmd's type do, but each line comes back as a real object you can pipe onward. -Tail is the one every incident responder reaches for: only the last N lines, without loading a huge file.
Practice Get-ContentUsage
Options and flags
-PathFILEthe file to read (first positional parameter)
-TotalCount, -First, -HeadNonly the first N lines; it stops reading there, so it's instant even on a huge file
-TailNonly the last N lines — doesn't need to read the whole file first
-Waitkeep the file open and print new lines as they're added, like tail -f (Ctrl+C to stop)
Examples
Get-Content app.logPrint the whole file, line by line as objects.
Get-Content app.log -Tail 20Just the last 20 lines — a live log's most recent activity.
Get-Content export.csv -TotalCount 10Just the first 10 lines, enough to see a file's header.
Get-Content app.log -WaitKeep printing new lines as the log grows, until Ctrl+C.
Common mistakes
-Tail only trims what Get-Content already read — it still needs a file to read in the first place.