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.
Clear-EventLog -LogName 'MyPoshShell'
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.
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) .
When you check, our “MyPoshShell” log is not there anymore.
I hope you have enjoyed this series J .
I hope I will come soon with another series.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.