Get-Error

Get and display the most recent error messages from the current session.

Syntax
 Get-Error [[-Newest] Int32] [CommonParameters ]
 Get-Error [-InputObject PSObject] [CommonParameters ]
Key:
 -InputObject
 This parameter is used for pipeline input.
 -Newest
 Specifies the number of errors to display that have occurred in the current session.

Standard Aliases for Get-Error: gerr

The Get-Error cmdlet gets a PSExtendedError object that represents the current error details from the last error that occurred in the session.

Use Get-Error to display a specified number of errors that have occurred in the current session using the -Newest parameter.
The Get-Error cmdlet also receives error objects from a collection, such as $Error, to display multiple errors from the current session.

Examples

Get the most recent error details:

PS C:\> Get-ChildItem -Path /NoRealDirectory
PS C:\> Get-Error
List of actions & errors...

Get the last 6 error messages in the current session:

PS C:\> Get-Error -Newest 6

Send a collection of errors from $error to view detailed messages:

PS C:\> $Error | Get-Error

"Those who make no mistakes are making the biggest mistakes of all — they are attempting nothing new" ~ Anthony de Mello

Related PowerShell Cmdlets

Write-Error - Write an object to the error pipeline.

(追記) (追記ここまで)
Copyright © 1999-2026 SS64.com
Some rights reserved

AltStyle によって変換されたページ (->オリジナル) /