MyITGuy
5/15/2014 - 1:23 AM

PowerShell: Check if Event Log Source exists

PowerShell: Check if Event Log Source exists

[System.Diagnostics.EventLog]::SourceExists("MyScript")
[System.Diagnostics.EventLog]::LogNameFromSourceName("Source","MachineName")

[System.Diagnostics.Eventing.Reader.EventLogSession]::GlobalSession.GetLogNames() -contains 'Microsoft-Windows-Sysmon/Operational'