Description

The Remove-EventLog cmdlet deletes an event log file from a local or remote computer and unregisters all of its event sources for the log. You can also use this cmdlet to unregister event sources without deleting any event logs.

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.

CAUTION: This cmdlet can delete operating system event logs, which might result in application failures and unexpected system behavior.

Parameters

-ComputerName <string[]>

Specifies a remote computer. The default is the local computer.

Type the NetBIOS name, an Internet Protocol (IP) address, or a fully qualified domain name of a remote computer. To specify the local computer, type the computer name, a dot (.), or "localhost".

This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Remove-EventLog even if your computer is not configured to run remote commands.

Required?

false

Position?

2

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-LogName <string[]>

Specifies the event logs. Enter the log name (the value of the Log property; not the LogDisplayName) of one or more event logs , separated by commas. Wildcard characters are not permitted. This parameter is required.

-Confirm

-WhatIf

Describes what would happen if you executed the command without actually executing the command.

Required?

false

Position?

named

Default Value

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This command supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, OutBuffer, OutVariable, WarningAction, and WarningVariable. For more information, see about_CommonParameters.

Inputs and Outputs

The input type is the type of the objects that you can pipe to the cmdlet. The return type is the type of the objects that the cmdlet returns.

Inputs

None

You cannot pipe input to this cmdlet.

Outputs

None

This cmdlet does not return any output.

Notes

To use Remove-EventLog on Windows Vista and later versions of Windows, start Windows PowerShell with the "Run as administrator" option.

If you remove an event log and then re-create the log, you will not be able to register the same event sources. Applications that used the events sources to write entries to the original log will not be able to write to the new log.

When you unregister an event source for a particular log, the event source might be prevented from writing entries in other event logs.

Example 1

Example 2

C:\PS>remove-eventlog -logname MyLog, TestLog -computername Server01, Server02, localhost
Description
-----------
This command deletes the MyLog and TestLog event logs from the local computer ("localhost") and the Server01 and Server02 remote computers. The command also unregisters the event sources for these logs.

Example 3

C:\PS>remove-eventlog -source MyApp
Description
-----------
This command deletes the MyApp event source from the logs on the local computer. When the command completes, the MyApp program cannot write to any event logs.

Example 5

C:\PS>get-wmiobject win32_nteventlogfile -filter "logfilename='TestLog'" | foreach {$_.sources}
MyApp
TestApp
C:\PS> remove-eventlog -source MyApp
C:\PS> get-wmiobject win32_nteventlogfile -filter "logfilename='TestLog'"} | foreach {$_.sources}
TestApp
Description
-----------
These commands use the Get-WmiObject cmdlet to list the event sources on the local computer. You can these commands to verify the success of a command or to delete an event source.
The first command gets the event sources of the TestLog event log on the local computer. MyApp is one of the sources.
The second command uses the Source parameter of Remove-EventLog to delete the MyApp event source.
The third command is identical to the first. It shows that the MyApp event source was deleted.