Skip to content

Change PSScript resource to not exit on non-terminating errors#1554

Merged
SteveL-MSFT merged 7 commits into
PowerShell:mainfrom
SteveL-MSFT:haderrors
Jun 2, 2026
Merged

Change PSScript resource to not exit on non-terminating errors#1554
SteveL-MSFT merged 7 commits into
PowerShell:mainfrom
SteveL-MSFT:haderrors

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

The PSScript resource was too strict in that HadErrors simply means that $Error had errors in it including non-terminating (like SilentlyContinue) errors. Change is to emit a warning message but continue.

PR Context

Fix #1547

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the PSScript resource behavior so non-terminating PowerShell errors no longer fail resource execution, addressing issue #1547 by warning while continuing.

Changes:

  • Replaces the hard failure on $ps.HadErrors with a warning trace.
  • Adds a regression test for non-terminating errors continuing execution and preserving output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
resources/PSScript/psscript.ps1 Changes HadErrors handling from exit-on-error to warn-and-continue.
resources/PSScript/psscript.tests.ps1 Adds test coverage for non-terminating errors during get.

Comment thread resources/PSScript/psscript.tests.ps1 Outdated
@SteveL-MSFT SteveL-MSFT added this to the 3.2-Consider milestone Jun 1, 2026
Comment thread resources/PSScript/psscript.ps1
Comment thread resources/PSScript/psscript.ps1
Comment thread resources/PSScript/psscript.ps1
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Jun 2, 2026
Merged via the queue into PowerShell:main with commit f84e6e5 Jun 2, 2026
53 of 55 checks passed
@SteveL-MSFT SteveL-MSFT deleted the haderrors branch June 2, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows]PowerShellScript resources hampered by use of HadErrors

3 participants