Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#2,146 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig
Tech-Stack
powershell
Bereich
tooling

Rechercherichtung

Beginne mit den Plattform-Einstellungsdateien von core-6.1.0 unter Engine/Settings, insbesondere mit den Einträgen rund um Write-Log, und vergleiche die Listen der integrierten Cmdlets für Linux ARM, Linux, macOS und Windows. Entferne oder korrigiere anschließend Einträge, die nicht mit PowerShell ausgeliefert werden, führe dann Invoke-ScriptAnalyzer für die Reproduktion von Write-Log.psm1 aus und prüfe auf ähnliche Fehlwarnungen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Up-for-Grabs

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

Create a file called Write-Log.psm1 in your home directory and populate it with an empty function called Write-Log:

function Write-Log {
}

Install and run PSScriptAnalyzer against the file:

> Install-Module PSScriptAnalyzer

> Invoke-ScriptAnalyzer -Path ~\Write-Log.psm1

Expected behavior

PSScriptAnalyzer returns no findings because Write-Log is not a built-in cmdlet.

Actual behavior

RuleName                         Severity ScriptName     Line Message
--------                         -------- ----------     ---- -------
PSAvoidOverwritingBuiltInCmdlets Warning  Write-Log.psm1 1    'Write-Log' is a cmdlet that is included with PowerShell (version core-6.1.0-windows) whose definition should not be overridden

This behaviour should be reproducible cross-platform.

Troubleshooting

Write-Log was never shipped with any version of PowerShell, but it is erroneously defined as a built-in cmdlet:

https://github.com/PowerShell/PSScriptAnalyzer/blob/e2804796f43eab60f5d105f6bbaea83fb446a13d/Engine/Settings/core-6.1.0-linux-arm.json#L1391-L1395

https://github.com/PowerShell/PSScriptAnalyzer/blob/e2804796f43eab60f5d105f6bbaea83fb446a13d/Engine/Settings/core-6.1.0-linux.json#L1391-L1395

https://github.com/PowerShell/PSScriptAnalyzer/blob/e2804796f43eab60f5d105f6bbaea83fb446a13d/Engine/Settings/core-6.1.0-macos.json#L1391-L1395

https://github.com/PowerShell/PSScriptAnalyzer/blob/e2804796f43eab60f5d105f6bbaea83fb446a13d/Engine/Settings/core-6.1.0-windows.json#L1692-L1696

Probable cause is described in https://github.com/PowerShell/PowerShell/issues/7209 as an upstream issue in PSDesiredStateConfiguration that was reportedly fixed in 2020. However, the PSScriptAnalyzer files affected by that issue were never rebuilt afterwards.

The module that may have caused this problem at the time is https://github.com/microsoft/PowerShellForGitHub, which defines Write-Log and then suppresses PSScriptAnalyzer reports in Helper.ps1#L128. The PR to suppress that finding is recorded in https://github.com/microsoft/PowerShellForGitHub/pull/180. If this module was present in the build environment, then PSScriptAnalyzer would have added Write-Log and possibly other cmdlets to the list of built-in cmdlets even though they do not ship with PowerShell.

As a result, default installations of PSScriptAnalyzer return a false warning for PSAvoidOverwritingBuiltInCmdlets against cmdlets named Write-Log.

It is possible that there may be other cmdlets erroneously included in these files for the same reason.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.24.0
Vorherrschende Sprache
C#
Sterne
2.2k
Forks
415
Ø Merge
13 Std. 1 Min.
Gemergte PRs (30 T.)
2

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus PowerShell/PSScriptAnalyzer

Alle Issues in PowerShell/PSScriptAnalyzer

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.