Use this topic when a script/command works on one machine but not another, output differs from expectation, cmdlets are missing, pipelines fail, execution policy blocks loading, remoting fails, or a command reports success but the target does not behave correctly.
PowerShell Troubleshooting
PowerShell troubleshooting checks the PowerShell version and exact command line first, then whether the right command and module were loaded, what input it received, and the full error record ($Error[0] | Format-List * -Force), instead of changing syntax at random.
1. $PSVersionTable — version on both machines.
2. Get-Command <name> — same command and module?
3. $Error[0] | fl * -Force — full error.
4. Run with -Verbose / Set-PSDebug -Trace 1.
5. Compare with pwsh -NoProfile to exclude profile effects.
version → module/command resolution → parameters → execution → error details
Perform the narrow next test inside the failed boundary, then rerun end-to-end verification after remediation.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Avoid reinstalling PowerShell or resetting WinRM as first steps. Avoid broad ExecutionPolicy/TrustedHosts changes. Do not stringify object pipelines to “make them work” before proving the original type/binding mismatch. Do not discard full error records.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
Use differential tests: -NoProfile, a clean shell, explicit module import, one representative object, local vs remote, Windows PowerShell vs PowerShell 7 only when compatibility is in question. Change one variable at a time and preserve before/after evidence.
Step 2 Known-good, broken and when it is fixed Verify boundary
Known-good means the script/module runs in the actual target host/session with expected object types, exit/error behavior and intended side effect, then succeeds again in the original automation path. Broken evidence is host/module mismatch, parameter/type error, remoting/session constraint or an unhandled nonterminating error that leaves partial state. The limit of what it shows is not absence of red text; explicitly validate output objects, $?/exit semantics where relevant and the resulting system state.
Step 3 Native failure isolation and next-check logic Narrow the fault
Capture the exact error record including exception, category, fully qualified error ID and position rather than only the red message. Confirm PowerShell edition/version, module command resolution and parameter types; use $Error[0]/verbose/debug or transcript/logging as appropriate. If remote or scheduled execution differs, compare identity, session configuration, environment and filesystem/network access. Reduce the failing pipeline to the smallest object-producing step so formatting output is not mistaken for underlying data.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Always capture the exact PowerShell product/version before comparing systems.
- Command name alone is insufficient evidence; resolve source/module/type.
- Object type and pipeline binding are stronger evidence than formatted screen output.
- Execution policy, WinRM transport, remoting endpoint and target authorization are distinct layers.
- “No PowerShell error” is not the same as “desired target state verified.”
$PSVersionTable— PowerShell edition and versionGet-Command <name>— which cmdlet/function/exe runsGet-Help <cmdlet> -Full— syntax and parametersGet-ExecutionPolicy -List— execution policy per scope
ReferenceWhat it is1 section · depth on demand
Core model
Troubleshooting should begin by freezing context: exact command/script, timestamp, user, host, $PSVersionTable, working directory, profile state and module/command source. This prevents a session-dependent difference from being mistaken for a code defect.
ReferenceHow it works1 section · depth on demand
How it works
PowerShell execution depends on host/version, module discovery, execution policy/signing, language mode, session scope, remoting context, object types and the underlying .NET/native command behavior. Text that looks correct can still have type, quoting, pipeline or scope differences. A script that works interactively may fail under Task Scheduler, WinRM or service automation because identity, profile, working directory and environment differ.
ReferenceImportant terms & boundaries3 sections · depth on demand
PowerShell boundary
Then classify the failure point. Parse/binding failures happen before command action. Module/command discovery failures are local session problems. Remoting failures require transport/auth/endpoint separation. Native-process failures need exit-code handling. A state-changing command with clean output still requires a target query.
In depth
Execution policy — why a script will not run
PS C:\> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy AllSigned
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine RemoteSigned
The first defined scope from the top wins; Group Policy (MachinePolicy/UserPolicy) overrides Set-ExecutionPolicy. Downloaded scripts carry a Zone.Identifier mark: under RemoteSigned they need a signature or Unblock-File. Execution policy is a safety feature, not a security boundary.
See the real error
$Error[0] | Format-List * -Force
$Error[0].InvocationInfo.PositionMessage
$Error[0].Exception.GetType().FullName
Get-Error # PowerShell 7: full error with inner exceptions
Make failures stop the script
| Setting | Effect |
|---|---|
$ErrorActionPreference = 'Stop' | Non-terminating errors become terminating — try/catch works |
-ErrorAction Stop on a cmdlet | Same, for one call |
Set-StrictMode -Version Latest | Errors on undefined variables and properties |
$LASTEXITCODE | Exit code of native programs (robocopy, git) — not covered by try/catch |
Version and host differences
| Problem | Check |
|---|---|
| Cmdlet missing | $PSVersionTable; Windows PowerShell 5.1 vs PowerShell 7 module compatibility |
| Module not found | Get-Module -ListAvailable Name; $env:PSModulePath differs between users and services |
| Works interactively, fails as a scheduled task | Profile not loaded, different user, working directory, 32-bit host (SysWOW64) |
| Output truncated in logs | Format cmdlets in pipelines; use Out-String -Width 4096 or export to CSV/JSON |
Record what happened
Start-Transcript -Path C:\Logs\job-$(Get-Date -f yyyyMMdd-HHmm).txt
...
Stop-Transcript
For security monitoring enable Script Block Logging via GPO (event 4104 in Microsoft-Windows-PowerShell/Operational), which records the code that actually ran.
*The execution-policy table illustrates scope precedence and is not a policy read-back from a real workstation.*
Method
PowerShell troubleshooting deals with scripts that fail, behave differently in different hosts, or cannot run because of policy.
$PSVersionTable
Get-ExecutionPolicy -List
$Error[0] | Format-List * -Force
Set-PSDebug -Trace 1
Set-StrictMode -Version Latest
Get-Module -ListAvailable ActiveDirectory
Start-Transcript -Path C:\Temp\run.log
| Symptom | Cause |
|---|---|
| "running scripts is disabled" | Execution policy |
| Works in ISE/VS Code, fails in scheduler | Different user, working directory, profile, 32/64-bit host |
| Cmdlet not found | Module missing or PowerShell 5.1 vs 7 differences |
try/catch does not catch | Non-terminating error — use -ErrorAction Stop |
| Remote command fails | WinRM, double-hop credentials |
Run scheduled scripts with pwsh -NoProfile -File and log with transcripts to see exactly what happened.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in PowerShell → PowerShell Troubleshooting. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/powershell/ · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
PowerShell → PowerShell Troubleshooting reference map
Fast lookup boundaries for PowerShell → PowerShell Troubleshooting.
| Item | Meaning | Evidence boundary |
|---|---|---|
| Host mismatch | powershell.exe vs pwsh.exe/version | changes runtime/modules/behavior |
| Command mismatch | alias/function/cmdlet/module/native | same name can resolve differently |
| Object/binding mismatch | wrong type/property/cardinality | pipeline may fail before target |
| Remote mismatch | transport/auth/endpoint/authz | must isolate layer |
| Target mismatch | command completed; state wrong | requires independent verification |