Scripting. Powershell, VMware, Windows, Active Directory & Exchange. All that kind of stuff…..
RSS icon Email icon Home icon
  • PowerShell 2.0: One Cmdlet at a Time #13 Clear-EventLog

    Posted on December 4th, 2009 Jonathan Medd No comments

    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()
    

    1000 things 1% better!

    Leave a reply