Monday, January 6, 2014

Part-7: Working with Event Logs using PowerShell :- Clearing Event Entries and Removing Event Log.

 

Part-1: Working with Event Logs using PowerShell

Part–2 : Working with Event Logs using PowerShell :- Get-EventLog

Part–3 : Working with Event Logs using PowerShell :- Get-EventLog

Part–4 : Working with Event Logs using PowerShell :- Get-WinEvent

Part–5 : Working with Event Logs using PowerShell :- Get-WinEvent

Part–6 : Working with Event Logs using PowerShell :- Creating New Event Logs and Event Entries

 

 

 

In my previous post, we talk about the usage of, New-EventLog and Write-EventLog, and we are almost at completion of this series.

Today we are going to use two more PowerShell cmdlets, Clear-EventLog and Remove-EventLog.

 

Clear-EventLog

 

It’s a very simple cmdlet, if you want to clear all event entries from any event log, you can use Clear-EventLog to clear it.

In our “MyPoshShell” event log, you can see there are 4 event entries. Let’s clear our event log.

Note: You have to run these cmdlets as Administrator.

clip_image002

 

Clear-EventLog -LogName 'MyPoshShell'

 

clip_image004

 

Now let’s see if out log is cleared or not, and indeed it is. You can see there are no event entries in the log now.

clip_image006

 

 

Remove-EventLog

 

It’s also another straight forward cmdlet like Clear-EventLog, usage is very simple, type the cmdlet and provide the name of the event log, which you want to delete.

This cmdlet remove complete log, not just entries.

Let’s remove our previously created “MyPoshLog”.

Remove-EventLog -LogName 'MyPoshShell'

Once you run the cmdlet, open the “Event Viewer” and see if logs is still their ;o) .

clip_image007

When you check, our “MyPoshShell” log is not there anymore.

clip_image008

 

 

I hope you have enjoyed this series J .

I hope I will come soon with another series.

 

Regards
Aman Dhally
clip_image017 clip_image018 clip_image019 clip_image020  clip_image021

 

               

No comments:

Post a Comment