Some PowerShell commands or cmdlets – Part 5 – EventLog related


Grouping event logs:
Get-EventLog -Logname application -Entrytype error | sort source | group source

72014_1 group
Grouping event logs in Descending order:
Get-EventLog -Logname application -Entrytype error | sort source |group source | sort count -Descending

72014_1 group count descending
Running a faster script:
Get-EventLog -LogName application | where { $_.timegenerated -gt [datetime]”7/01/14″ }
This command took 11 seconds to complete (It lists all application log events in the last 20 days e.g. today date being 07/20/2014

Get-EventLog -LogName application -after 7/01/14
This command took 8 seconds to complete e (It lists all application log events in the last 20 days e.g. today date being 07/20/2014
So, the above two commands accomplish the same task but, the latter took 3 seconds less because the filtering was done on the left side of the pipeline, or without a need of a pipeline operator
So try filtering to the left if possible

Measuring the time it tales to run a command:
Measure-command { Get-EventLog -LogName application -after 7/01/14 }

72014_3 measure command

So, it took 3696 miliseconds or approximately 4 seconds to execute the command

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: