Search This Blog

Showing posts with label Microsoft.PowerShell. Show all posts
Showing posts with label Microsoft.PowerShell. Show all posts

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



API Authentication

Reference · Identity & Access API Authentication Methods Four common ways a client proves who it is to a server, ord...

Recent Post