Command referenceGet-Content
Get-Content command (Windows / PowerShell)
What it does
Read file content or provider data as a stream of objects. Guides covering the get-content powershell usually need pipeline-friendly examples, common parameters, and how the cmdlet compares with classic CMD or Linux tools. This page includes syntax, options, and copyable PowerShell examples.
Read file content or provider data as a stream of objects.
Syntax
Get-Content [-Path] <String[]> [-TotalCount <Int64>] [-Tail <Int32>] [-Wait] [-Raw]
Common options
| Flag / option | Meaning |
|---|---|
| -Raw | Return the whole file as one string. |
| -Tail | Return the final number of lines. |
| -Wait | Continue watching for appended content. |
| -TotalCount | Return only the first number of lines. |
| -Encoding | Choose the text encoding. |
Practical examples
Read lines
Get-Content .\app.log
Emits one string per line.
Read JSON whole
Get-Content .\config.json -Raw
Returns one multiline string suitable for ConvertFrom-Json.
Follow log
Get-Content .\server.log -Tail 20 -Wait
Shows recent lines and waits for new ones.
Linux ↔ Windows equivalent
Closest match: cat (Linux / bash / sh / zsh). Concatenate files and write their contents to standard output.
Common mistakes
- Forgetting `-Raw` when an API expects one complete string.
- Reading huge files entirely when streaming or filtering would use less memory.
Related commands
- Select-StringSearch strings and files with .NET regular expressions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- typeDisplay the contents of one or more text files.
- grepSearch text for lines matching a pattern.
- Where-ObjectFilter pipeline objects by property values or a script block predicate.
- catConcatenate files and write their contents to standard output.
- echoWrite arguments and shell-expanded values to standard output.
- echoDisplay text or control command echoing in a batch script.
FAQ
What does Get-Content do in PowerShell?
Read file content or provider data as a stream of objects.
How can I see examples for Get-Content?
Run `Get-Help Get-Content -Examples`, then adapt an example to the provider and objects you are using.
What is a practical Get-Content example?
Try `Get-Content .\app.log` — Emits one string per line.
Does Get-Content return text or objects?
Get-Content normally participates in PowerShell's object pipeline; formatting seen in the console is a view of those objects.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.