microsoft/upgrade-agent-plugins/replacing-eventlog-with-winevent
Claude Code and agent skill by microsoft/upgrade-agent-plugins
- vendor
Checking that the SKILL.md file is still in the repository.
Replace the removed *-EventLog cmdlets (Get-EventLog, Write-EventLog, New-EventLog, Clear-EventLog, Limit-EventLog, Show-EventLog, Remove-EventLog) with Get-WinEvent / New-WinEvent or System.Diagnostics.EventLog in PowerShell 7.x. Use during the powershell-51-to-7-upgrade scenario for the EventLog blocker bucket.
Install
npx vskill@latest install microsoft/upgrade-agent-plugins/replacing-eventlog-with-wineventSKILL.md
The same SKILL.md was published earlier as microsoft/upgrade-agent-plugins/replacing-eventlog-with-winevent.
EventLog → WinEvent Migration (PowerShell 7.x)
The classic *-EventLog cmdlets are removed in PowerShell 7. Use Get-WinEvent/New-WinEvent, or the System.Diagnostics.EventLog .NET type directly. These are Windows-only APIs — the scripts remain Windows-bound.
Reading events
Property name changes to expect:
| Get-EventLog | Get-WinEvent | |
|---|---|---|
EventID | Id | |
EntryType | LevelDisplayName / Level (1=Critical,2=Error,3=Warning,4=Info) | |
Source | ProviderName | |
TimeGenerated | TimeCreated | |
Message | Message |
EntryType and Level are different enums — translate, never pass through
[System.Diagnostics.EventLogEntryType] (what -EntryType took) and Get-WinEvent's Level do not share numbering:
| Meaning | EventLogEntryType | Get-WinEvent Level | |
|---|---|---|---|
| Critical | — | 1 | |
| Error | 1 | 2 | |
| Warning | 2 | 3 | |
| Information | 4 | 4 |
Forwarding an EntryType value straight into Level therefore asks for Critical when the script meant Error, and Error when it meant Warning. The script still parses, still passes Rung 2, and silently returns the wrong events — a monitoring script goes blind. Only Information survives by coincidence. Map explicitly:
Get-WinEvent throws where Get-EventLog returned empty
A missing provider or a filter that matches nothing is a terminating-style error, not an empty result. -ErrorAction SilentlyContinue is not sufficient: the cmdlet emits several errors per call and one still reaches the host. Use try/catch with -ErrorAction Stop:
Then iterate with foreach ($e in $events), not $events | ForEach-Object — piping $null runs the block once with $_ = $null, which turns "no events" into a null-reference error.
Writing events
Write-EventLog/New-EventLog are gone. Use the .NET type:
Or New-WinEvent when the provider is manifest-based.
Admin / clear operations
Clear-EventLog, Limit-EventLog, Remove-EventLog have no direct PS7 cmdlet. Use System.Diagnostics.EventLog (.Clear(), MaximumKilobytes) or wevtutil.exe for advanced cases.
Validation
- Rung 2 (PSScriptAnalyzer
PSUseCompatibleCommands) confirms no*-EventLog
remains. It cannot see an EntryType→Level mistranslation — that is a data-correctness bug, not a compatibility one, so a green Rung 2 does not clear this migration.
- Rung 4: reading is safe to diff (4b) and you should diff it — compare the
event ids/timestamps returned by the 5.1 and 7.x versions for the same filter, not just the row count. Writing/clearing mutates the log — validate in a sandbox or mark manual-signoff.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 24 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/upgrade-agent/upgrade/dotnet/skills/lazy/pwsh/replacing-eventlog-with-winevent/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/upgrade-agent-plugins/replacing-eventlog-with-winevent)