Remove-eventLog

Delete an event log or unregister an event source.

Syntax
      Remove-EventLog [-LogName] string[] [[-ComputerName] string[]]
        [-Confirm] [-WhatIf] [CommonParameters]

      Remove-EventLog [[-ComputerName] string[]] [-Source string[]]
        [-Confirm] [-WhatIf] [CommonParameters]

Key:
   -ComputerName string[]
       Specify 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.
       This parameter does not rely on PowerShell remoting.

   -LogName string
       The event logs to delete.
       Enter the log name (not the Display Name) of one or 
       more event logs , separated by commas.
       Wildcard characters are not permitted. This parameter is required.

   -Source string[]
Unregister the specified event sources. Enter the source names (not the executable name), separated by commas. -Confirm Prompt for confirmation before executing the command. -WhatIf Describes what would happen if you executed the command without actually executing the command. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.

Remove-EventLog will delete an event log file and unregister all of its event sources for the log. This cmdlet can also be used to unregister event sources without deleting any event logs.

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.

Examples

Delete the SS64 event log from the local computer and unregister its event sources:

PS C:\> remove-eventlog -logname SS64

Delete the MyApp event source from the logs on the local computer. Prevent the MyApp program from writing any event logs:

PS C:\> remove-eventlog -source MyApp

Write a new message to the Application eventlog:

PS C:\> $log = Get-EventLog -List | Where-Object { $_.Log -eq "Application" }
PS C:\> $log.Source = "Test"
PS C:\> $log.WriteEntry("Test message")

PS C:\> Get-EventLog Application -Newest 1 | Select Message

“No amount of time can erase the memory of a good cat, and no amount of masking tape can ever totally remove his fur from your couch” ~ Leo F. Buscaglia

Related:

Get-Eventlog - Get event log data
New-Eventlog
- Create a new event log and a new event source


© Copyright SS64.com 1999-2014
Some rights reserved