New
#50
Last edited by Brink; 25 Jul 2018 at 14:19.
This is what I'm getting.
As I Said, I've noticed it not closing only in the last few weeks or so. I should have paid attention when, it would probably coincide with an update. Very interesting...
Odd. Please try the updated .bat file now in the tutorial to see how it works for you.
Last edited by Brink; 26 Jul 2018 at 09:04.
That closes the command prompt. Just adding "Exit" at the end of the file works.
Thank you. A very small thing, but it was curious that the command prompt has been closing for years and only recently has it been staying open. I've never looked at the script until comparing it to yours.
Curious, without "Exit" it closes on your machine?
Yeah, it has always automatically closed without needing "Exit" for me. I'm glad it was able to sort it for you.
@Brink
Hi Shawn,
I was playing around, in PowerShell, with the event logs and I noticed that in Option 3 the first PowerShell command is the "old" (pre-Vista) one, which although successfully clears the events, it does it only for the Windows "classic" Event logs.
May I suggest a change in the tutorial to the "new" Get-WinEvent command?
As you can see from the screenshot below, the difference in the number of Event logs from each command is quite significant.
If we use the Get-WinEvent command, we cannot use the Clear-Eventlog, as it doesn't work, according to the Microsoft Clear-EventLog doc.
In that case we need to go to the .NET EventLogSession Class to clear the 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 the Get-WinEvent cmdlet.
If you believe that it's worth changing to the new PS command, the 1st command should be:
As always, you can test and evaluate it....and act accordingly!!!Code:Get-WinEvent -ListLog * | ForEach { [System.Diagnostics.Eventing.Reader.EventLogSession]::GlobalSession.ClearLog("$_.LogName") }
Hello Dimitri,
I tested your command, but all I got was red error messages in the elevated PowerShell, and Event Viewer did how anything cleared in "Windows Logs". Am I doing something wrong?
Using the first command in Option 3 did clear the "Windows Logs" like below.