Skip to main content

Command referenceGet-Content

Get-Content command (Windows / PowerShell)

WindowsPowerShelltextbeginner

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 / optionMeaning
-RawReturn the whole file as one string.
-TailReturn the final number of lines.
-WaitContinue watching for appended content.
-TotalCountReturn only the first number of lines.
-EncodingChoose 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.

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.