Built-in cmdlet

Get-Content cmdlet

Gets the content of the item at the specified location.

Availability: PowerShell version and module availability vary; check the installed system中文

Syntax

Get-Content [-Path] <string[]> [-TotalCount <long>] [-Tail <int>] [-Wait]

This is a practical syntax summary, not every parameter set. Run Get-Command Get-Content -Syntax and Get-Help Get-Content -Full in the installed version for its complete syntax and parameter metadata. Common parameters and -WhatIf/-Confirm support depend on the command and PowerShell version.

Examples

Example usage of Get-Content.

Get-Content -Path .\app.log -Tail 50 -Wait

Read all available parameter sets and help for the installed module.

Get-Help Get-Content -Full

Parameters, options and clauses

Option / clauseDescription
-Path / -LiteralPath <path[]>Select input files; LiteralPath does not expand wildcards.
-TotalCount <n>Read only the first n lines.
-Tail <n>Read only the last n lines.
-WaitKeep running and emit appended content as it arrives.
-Raw / -Encoding <name>Return one string or choose a text encoding where supported.
-VerboseWrite additional diagnostic detail to the verbose stream.
-DebugWrite debugging messages to the debug stream.
-ErrorAction <action>Control how a non-terminating error is handled.
-ErrorVariable <name>Store error records in a variable.
-WarningAction <action>Control how warnings are handled.
-WarningVariable <name>Store warning messages in a variable.
-InformationAction <action>Control how information messages are handled.
-InformationVariable <name>Store information messages in a variable.
-OutVariable <name>Store output in a variable as well as sending it onward.
-OutBuffer <count>Set the number of objects to collect before the next command runs.
-PipelineVariable <name>Store the current pipeline object in a variable during processing.
-ProgressAction <action>Control progress reporting in versions that support this parameter.
-WhatIf / -ConfirmRisk-control parameters available only on commands that support ShouldProcess.

Related PowerShell references

Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory