Search This Blog

Thursday, 31 August 2017

Export unique event log in text file using Microsoft.PowerShell

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.

Rerefence



3 comments:

  1. I am from a Architect Technologies background, and now looking for a change in Microsoft Azure Architect Technologies. Now since do not have much knowledge of Azure Architect Technologies Exam. Will Architect Technologies exam help in getting a decent job? Also You can prepare yourself for the AZ-300 questions to get Microsoft Azure Architect Technologies Certification Transition credentials.

    ReplyDelete

Elasticsearch - Nodes, clusters, and shards

Elastic Stack Video - Load your gun in short time.   Beginner's Crash Course to Ela...

Recent Post