PowerShell Logo Small

Clear-EventLog



This is the built-in help made by Microsoft for the command 'Clear-EventLog', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Deletes all entries from specified event logs on the local or remote computers.

SYNTAX


Clear-EventLog [-LogName] <String[]> [[-ComputerName] [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}]
[-InformationVariable [<System.String]>]] [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Clear-EventLog cmdlet deletes all of the entries from the specified event logs on the local computer or on remote computers. To use Clear-EventLog, you must be a member
of the Administrators group on the affected computer.


The cmdlets that contain the EventLog noun (the EventLog cmdlets) work only on classic event logs. To get events from logs that use the Windows Event Log technology in
Windows Vista and later versions of Windows, use Get-WinEvent.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=289799
Get-EventLog
Limit-EventLog
New-EventLog
Remove-EventLog
Show-EventLog
Write-EventLog

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>clear-eventlog "Windows PowerShell"



This command deletes the entries from the "Windows PowerShell" event log on the local computer.










-------------------------- EXAMPLE 2 --------------------------

PS C:\>clear-eventlog -logname ODiag, OSession -computername localhost, Server02



This command deletes all of the entries in the Microsoft Office Diagnostics (ODiag) and Microsoft Office Sessions (OSession) logs on the local computer and the Server02
remote computer.










-------------------------- EXAMPLE 3 --------------------------

PS C:\>clear-eventlog -log application, system -confirm



This command prompts you for confirmation before deleting the entries in the specified event logs.










-------------------------- EXAMPLE 4 --------------------------

PS C:\>function clear-all-event-logs ($computerName="localhost")
{
$logs = get-eventlog -computername $computername -list | foreach {$_.Log}
$logs | foreach {clear-eventlog -comp $computername -log $_ }
get-eventlog -computername $computername -list
}

PS C:\>clear-all-event-logs -comp Server01

Max(K) Retain OverflowAction Entries Log
------ ------ -------------- ------- ---
15,168 0 OverwriteAsNeeded 0 Application
15,168 0 OverwriteAsNeeded 0 DFS Replication
512 7 OverwriteOlder 0 DxStudio
20,480 0 OverwriteAsNeeded 0 Hardware Events
512 7 OverwriteOlder 0 Internet Explorer
20,480 0 OverwriteAsNeeded 0 Key Management Service
16,384 0 OverwriteAsNeeded 0 Microsoft Office Diagnostics
16,384 0 OverwriteAsNeeded 0 Microsoft Office Sessions
30,016 0 OverwriteAsNeeded 1 Security
15,168 0 OverwriteAsNeeded 2 System
15,360 0 OverwriteAsNeeded 0 Windows PowerShell



This function clears all event logs on the specified computers and then displays the resulting event log list.

Notice that a few entries were added to the System and Security logs after the logs were cleared but before they were displayed.