Skip to content

Fix false-positive Write-Log warnings in built-in cmdlet rule - #2303

Open
S.H Jeong (z0rimo) wants to merge 1 commit into
PowerShell:mainfrom
z0rimo:fix/2146-write-log-false-positive
Open

S.H Jeong (z0rimo) wants to merge 1 commit into
PowerShell:mainfrom
z0rimo:fix/2146-write-log-false-positive

Conversation

@z0rimo

Copy link
Copy Markdown

PR Summary

Fixes #2146.

PSAvoidOverwritingBuiltInCmdlets incorrectly reports user-defined Write-Log functions as overwriting a built-in PowerShell command.

The four PowerShell 6.1 command profiles contain a stale Write-Log entry exported by PSDesiredStateConfiguration. This originates from a historical DSC issue where internal helper functions were unintentionally exported (PowerShell/PowerShell#7209).

Changes:

  • Remove the erroneous Write-Log entry from the Windows, Linux, Linux ARM, and macOS core-6.1.0-* profiles.
  • Add regression tests covering all four profiles and the default rule configuration.
  • Verify that actual built-in commands such as Get-ChildItem continue to produce warnings.

The change is limited to the affected JSON entries and regression tests. No C# rule logic or unrelated compatibility data is modified.

Validation:

  • Regression tests reproduced the issue before the fix (Expected 1, but got 2) and passed afterward.
  • AvoidOverwritingBuiltInCmdlets: 12 passed.
  • UseCompatibleCommands: 200 passed.
  • UseCompatibleCmdlets: 14 passed.
  • AvoidUsingAlias: 11 passed, 1 skipped.
  • All four modified JSON files validated successfully.
  • git diff --check passed.

Testing notes:

The repository pins .NET SDK 8.0.419, which was unavailable locally. The build and tests were run using SDK 10 against a scratchpad copy. SHA256 checks confirmed that the modified source files matched the tested copy and that the JSON files matched the built module's Settings files.

The broader AllCompatibilityRules.Tests.ps1 suite was not completed locally due to its execution time and CPU usage. CI validation is pending.

PR Checklist

Copilot AI balanced review requested due to automatic review settings November 18, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the PowerShell 6.1 profile-data correction addressing false positives for user-defined Write-Log functions.

No open issues 🎉

What changed in this PR

Fixes #2146 by correcting PowerShell 6.1 command profiles so PSAvoidOverwritingBuiltInCmdlets no longer flags user-defined Write-Log functions. The fix updates profile data without changing rule logic.

Changes:

  • Remove stale Write-Log entries from all four PowerShell 6.1 profiles.
  • Add regression tests for explicit profiles and default settings, confirming that Get-ChildItem overrides still produce warnings.
File Description
Tests/​Rules/​AvoidOverwritingBuiltInCmdlets.tests.ps1 Add regression coverage for Write-Log and genuine built-in overrides.
Engine/​Settings/​core-6.1.0-windows.json Remove the stale Windows Write-Log entry.
Engine/​Settings/​core-6.1.0-macos.json Remove the stale macOS Write-Log entry.
Engine/​Settings/​core-6.1.0-linux.json Remove the stale Linux Write-Log entry.
Engine/​Settings/​core-6.1.0-linux-arm.json Remove the stale Linux ARM Write-Log entry.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PSAvoidOverwritingBuiltInCmdlets (core-6.1.0-*) returns warning for Write-Log, which is not a built-in cmdlet

2 participants