Example 1: Get event logs on the local computer
In the below give below result
- Get the ten most recent entries from a specific event log on the local computer, This command gets the ten most recent entries from the Application event log.
- Get error, warning events from a specific event log. E.g. "Error"
- Get all errors in an event log that occurred during a specific time frame
- Get the unique entries from a specific event log on the local computer.
- Get the MachineName, Source, EntryType, Message properties from entries from a specific event log on the local computer.
- Export the EventLog in text file to specific server location.
Script
$AfterDate = (Get-Date -Date '26/8/2017'); $Message = Get-EventLog -LogName "Application" -EntryType Error, Warning -Newest 10 -Source "BizTalk Server" -After $AfterDate -ComputerName "localhost" $Message = $Message | Format-List -Property MachineName, Source, EntryType, Message $Message = $Message | select -uniq; $Message >> \\ServerName\c$\Users\harshal.chaudhari\SystemErrors.txt
Result
MachineName : ServerName Source : BizTalk Server EntryType : Warning Message : An error occurred that requires the BizTalk service to terminate. The most common causes are the following: 1) An unexpected out of memory error. OR 2) An inability to connect or a loss of connectivity to one of the BizTalk databases. The service will shutdown and auto-restart in 1 minute. If the problematic database remains unavailable, this cycle will repeat.