Pcornel
Automation · PowerShell Automation

PowerShell Troubleshooting

Cheat sheet · https://pcornel.dk/topic.php?topic=5254

Back to the Topic

Answer

Troubleshoot PowerShell scripts with Set-PSDebug, Write-Verbose and -Verbose, inspecting $Error[0] | Format-List * -Force, the execution policy, module versions and the PowerShell edition in use.

Remember

  • Read full error record.
  • Check edition and modules.
  • Check execution policy.

First checks

  • $Error[0] | Format-List * -Force — error details
  • Set-PSDebug -Trace 1 — trace
  • Start-Transcript -Path log.txt — capture session

Commands

$Error[0] | Format-List * -Force
Read-only/validation observation for the newest PowerShell ErrorRecord including exception, category, target object and…

Verify in this order

error → details → environment → fix → test

Where it usually breaks

Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.

PowerShell Troubleshooting · PowerShell operational reference

BoundaryPowerShell Troubleshooting reference
Runtime identityPowerShell edition/version + command/module source
Persistent intentScript/module/config prerequisites under source control
VerificationRead-only discovery → execution evidence → independent target read-back
Output contractStructured objects/streams before formatting
Failure boundarySeparate engine/binding from transport/API/native and target-state failures

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5254

Confirmation

Confirm action

Continue?