[release/v7.4] Fix $PSDefaultParameterValues leak causing tests to skip unexpectedly#26869
Merged
adityapatwardhan merged 1 commit intoPowerShell:release/v7.4from Feb 20, 2026
Conversation
…PowerShell#26602) This fixes test isolation issues where six test files were leaking $PSDefaultParameterValues["It:Skip"] settings to subsequent tests, causing widespread test skipping on Linux. The fixes address two distinct patterns: using .Remove() which doesn't restore the original state (4 files), and imbalanced Push-DefaultParameterValueStack/Pop-DefaultParameterValueStack calls (2 files).
Contributor
There was a problem hiding this comment.
Pull request overview
Backport to release/v7.4 that fixes Pester test isolation issues where $PSDefaultParameterValues changes (notably It:Skip) leaked across test files and caused unexpected skips on Linux CI runs.
Changes:
- Restore
$PSDefaultParameterValuesfrom a cloned snapshot inAfterAll/finallyblocks instead of using.Remove(...). - Fix an imbalanced
Push-DefaultParameterValueStack/Pop-DefaultParameterValueStackpair by ensuringPop-DefaultParameterValueStackis called when a skip path is taken. - Remove an extra/unmatched
Pop-DefaultParameterValueStackin a remoting test to prevent stack underflow/leaks.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/powershell/engine/Security/FileSignature.Tests.ps1 | Ensures Pop-DefaultParameterValueStack executes when the suite is skipped, preventing leaked default parameters. |
| test/powershell/engine/Remoting/SessionOption.Tests.ps1 | Clones and restores $PSDefaultParameterValues in try/finally to avoid persistent it:skip settings. |
| test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 | Removes an unmatched Pop-DefaultParameterValueStack; keeps pop only for the skip path. |
| test/powershell/engine/ETS/CimAdapter.Tests.ps1 | Restores full $PSDefaultParameterValues state after setting it:pending on non-Windows. |
| test/powershell/Modules/Microsoft.PowerShell.Security/AclCmdlets.Tests.ps1 | Restores full $PSDefaultParameterValues state after setting It:Skip for non-Windows. |
| test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 | Restores full $PSDefaultParameterValues state after setting it:skip for non-Windows. |
adityapatwardhan
approved these changes
Feb 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #26602 to release/v7.4
Triggered by @TravisEz13 on behalf of @app/copilot-swe-agent
Original CL Label: CL-Test
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Fixes test isolation to prevent $PSDefaultParameterValues["It:Skip"] from leaking across tests on Linux.
Customer Impact
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Not run locally; original PR describes reproduction and fixes.
Risk
REQUIRED: Check exactly one box.
Changes are limited to test scripts.