PowerShell Remove-EventLog Cmdlet
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed Clear-EventLog cmdlet in PowerShell.
https://cloudaffaire.com/powershell-clear-eventlog-cmdlet/
In this blog post, we will discuss Remove-EventLog cmdlet in PowerShell. You can use Remove-EventLog cmdlet to delete an event log file. Remove-EventLog cmdlet can also be used to unregister an event source from an event log. You need to have administrator access to order to delete an event log or unregister its source. You can use Remove-EventLog cmdlet to delete the event log of a local or remote computer.
Note: This cmdlet has the potential to cause trouble for your OS or application, hence use carefully.
Remove-EventLog Cmdlet Syntax:
1 2 3 4 5 6 |
## Remove-EventLog ## [[-ComputerName] ## [-LogName] ## [-WhatIf] ## [-Confirm] ## [ |
Remove-EventLog Cmdlet Argument List:
- –ComputerName: Specifies remote computers. The default is the local computer.
- –Confirm: Prompts you for confirmation before running the cmdlet.
- –LogName: 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.
- –Source: Specifies the event sources that this cmdlet unregisters. Enter the source names, not the executable name, separated by commas.
- –WhatIf: Shows what would happen if the cmdlet runs. The cmdlet is not run.
PowerShell Remove-EventLog Cmdlet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
########################################### ## PowerShell | Cmdlet | Remove-EventLog ## ########################################### ## PowerShell Latest Version (5) ## run PowerShell as admin ## create a sample file New-Item -ItemType File -Path C:\myfile.dll -Value "hello world" ## create a new event log New-EventLog -source MySource -LogName MyLog -MessageResourceFile C:\myfile.dll ## get event log details Get-WinEvent -ListLog MyLog | Select-Object * ## unregister the event log source Remove-EventLog -Source "MySource" ## delete the event log Remove-EventLog -LogName "MyLog" Remove-Item -Path C:\myfile.dll |
Hope you have enjoyed this article. In the next blog post, we will discuss New-PSSession CmdLet in PowerShell.
To Set more details on PowerShell, kindly follow below official documentation