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

Get-WinEvent instead of Get-EventLog

Offen
#443 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
powershell

Rechercherichtung

Untersuchen Sie Get-WindowsEventLogRestrictGuestAccess und Set-WindowsEventLogRetentionDays in der Nähe der Zeilen 717 und 971, beginnend mit den gemeldeten Get-EventLog-Aufrufen. Ersetzen Sie diese Aufrufe durch die vorgeschlagene Get-WinEvent-Abfrage und überprüfen Sie anschließend, dass die WindowsEventLog-Ressource mit PowerShell 7 unter Windows Server 2019 funktioniert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Problem description

Get-EventLog is deprecated in favor of Get-WinEvent and when trying to use WindowsEventLog from ComputerManagemntDsc with GuestConfig Agent I am getting an error message like the following

Verbose logs
The term 'Get-EventLog' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. The PowerShell DSC resource '[WindowsEventLog]LOG_NAME' with SourceInfo 'E:\agent\_work\1212\dev\build\configurations\dev\WindowsEventLog_LOG_NAME.ps1::6::9::WindowsEventLog' threw one or more non-terminating errors while running the Test-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details. The SendConfigurationApply function did not succeed. LCM failed to start desired state configuration manually.
DSC configuration
Configuration WindowsEventLog_LOG_NAME
{
    Import-DSCResource -Name WindowsEventLog -ModuleName ComputerManagementDsc -ModuleVersion 10.0.0
    Node localhost
    {
        WindowsEventLog LOG_NAME
        {
            LogName           = 'LOG_NAME'
            RegisteredSource  = 'LOG_NAME'
            IsEnabled         = $true 
        }
    }
}

WindowsEventLog_LOG_NAME -OutputPath .\mof-files\WindowsEventLog_LOG_NAME\
Suggested solution

Remove Get-EventLog from the following functions Get-WindowsEventLogRestrictGuestAccess and Set-WindowsEventLogRetentionDays

Replace 717 and 971 with the following code

$matchingEventLog = Get-WinEvent -ListLog $Logname -ErrorAction Stop

Operating system the target node is running
OsName               : Microsoft Windows Server 2019 Standard
PowerShell version and build the target node is running
PowerShell ver 7 is what our build and deploy pipeline are running
ComputerManagementDsc version
Version 10
Vorherrschende Sprache
PowerShell
Sterne
338
Forks
80
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

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 dsccommunity/ComputerManagementDsc

Alle Issues in dsccommunity/ComputerManagementDsc

Ähnliche Issues

Weitere Issues zu DevOps

Neue Issues direkt in Ihr Postfach

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