# PowerShell Function/Cmdlet to clear one of the Application and Service Logs We can use the built-in Get-WinEvent cmdlet / function to list the logs. Our second task is to pick-out one of the Application and Service logs to test the function. I found this task harder than I anticipated, and this is why I recommend the -Confirm parameter when testing. The first task should be to backup, or at least copy, the logs under: PowerShell Solution 1: Create Clear-WinEvent Let us apply the parameter -LogName to a named log file however for safety, please include the -Confirm parameter, which is especially useful if you plan to modify the script to zero all the logs. Our mission is to build a cmdlet function called Clear-WinEvent. These are the same logs that you could find, and back up, in theĪt the heart of the script is this EventLog class from. Orientation to the Location : I am talking about the 150+ Application and Services Logs that you see in Event Viewer. Rather than slavishly copying my script below, I recommend that you take the time to assimilate the overall plan. Creating a Function Called Clear-WinEvent.Solution 1: Create Clear-WinEvent Function.To avoid disaster by being too gung-ho, I recommend that you practice with Get-WinEvent and Clear-Eventlog before you try my examples on this page. Our mission is to 'zero' those dozens of Windows event logs that don't respond to PowerShell's native command: Clear-Eventlog.