Skip to content

Resolve‑ShpError

Raimund edited this page Jul 28, 2026 · 1 revision

SYNOPSIS

Asks Copilot to explain and fix the last error in the session.

SYNTAX

Resolve-ShpError [[-ErrorRecord] <ErrorRecord>] [[-Model] <String>] [-EnableTools] [[-Instruction] <String>]
 [<CommonParameters>]

DESCRIPTION

Takes an error record - by default the most recent one in $Error - and sends it to the model together with the command that produced it, its category, target and script stack trace, then returns the model's diagnosis and suggested fix.

This is the "what just went wrong?" shortcut: instead of copying an exception into a prompt by hand, run Resolve-ShpError straight after a failure. All the browsing and tool switches of Invoke-Shp are off by default here, because diagnosing an error needs no tools; pass -EnableTools to let the model read files or run commands while it investigates.

EXAMPLES

EXAMPLE 1

Get-Item /nope
Resolve-ShpError

Explains the most recent error and suggests a fix.

EXAMPLE 2

$Error[2] | Resolve-ShpError -Model claude-opus-5

Explains an older error from the session using a specific model.

PARAMETERS

-EnableTools

Let the model use the file and terminal tools while diagnosing. Off by default, so a plain Resolve-ShpError only reads the error text you already have and cannot touch the machine.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ErrorRecord

The error to explain. Defaults to $Error[0], the most recent error in the session. Accepts pipeline input, so $Error[3] | Resolve-ShpError works.

Type: ErrorRecord
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-Instruction

Extra guidance appended to the built-in diagnostic system prompt, for example 'answer with a corrected one-liner only'.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Model

The model id to use. Defaults to the session default model, exactly as Invoke-Shp does when the parameter is omitted.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Management.Automation.PSCustomObject

The Invoke-Shp result object, so Content, Usage and CostUSD are all

available.

NOTES

RELATED LINKS

Invoke-Shp

Clone this wiki locally