PowerShell 2.0: One Cmdlet at a Time 13 Clear-EventLog
Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Clear-Eventlog cmdlet.
What can I do with it?
Clear the Event Log on a local or remote computer.
Example:
Clear the Application Event Log on the remote computer Server01
Clear-EventLog -LogName Application -ComputerName Server01
How could I have done this in PowerShell 1.0?
You could have used the Get-EventLog cmdlet and the Clear method of the System.Diagnostics.EventLog object it generates. (Note: this would only work on a local computer)
$ApplicationLog = Get-EventLog -list | Where-Object {$_.log -eq “Application”} $ApplicationLog.Clear()