miércoles, 9 de marzo de 2022

WINDOWS. PS. Eventvwr insert event

 Purpose

Write a event into Windows eventViewer. It is very util to register some task.

Dificulty: Low 

COMMAND:

if(-not([System.Diagnostics.EventLog]::SourceExists("MySourcex"))){
    New-EventLog -LogName 'Application' -Source 'MySourcex'
}
Write-EventLog -LogName 'Application' -Source 'MySourcex' -EventId 6123 -EntryType Information -Message 'Check Test Log 66123 GoB'



References:

 https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlog.sourceexists?redirectedfrom=MSDN&view=dotnet-plat-ext-6.0#overloads

 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/write-eventlog?view=powershell-5.1


by GoN | Published: Mar 9, 2022 | Last Updated: