Clear all event logs on Windows using PowerShell

I was bored with the vast amount of data in the eventlogs which were really not useful for me. So, in order to improve readability on my machine I decided to look for something to clear all of the eventlogs. Easy.

Since I always use the Administrative Events filter to view every warning and error I get a lot of junk (who cares for Kernel-Power warnings?)

Administrative Events

Since I didn’t feel like doing the following steps for each frigging event log there is on my machine. You would need to go to the following steps:

Step 1

Step 2

Now this is an excerpt  from the eventlogs I have on this machine:

Analytic
Application
DirectShowFilterGraph
DirectShowPluginControl
EndpointMapper
ForwardedEvents
HardwareEvents
Internet Explorer
Key Management Service
MF_MediaFoundationDeviceProxy
MediaFoundationDeviceProxy
MediaFoundationPerformance
MediaFoundationPipeline
MediaFoundationPlatform
Microsoft-IE/Diagnostic
Microsoft-IEDVTOOL/Diagnostic
Microsoft-IEFRAME/Diagnostic
Microsoft-IIS-Configuration/Administrative
Microsoft-IIS-Configuration/Analytic
Microsoft-IIS-Configuration/Debug
Microsoft-IIS-Configuration/Operational
Microsoft-PerfTrack-IEFRAME/Diagnostic
Microsoft-PerfTrack-MSHTML/Diagnostic
Microsoft-Windows-ADSI/Debug
Microsoft-Windows-API-Tracing/Operational
Microsoft-Windows-ATAPort/General
Microsoft-Windows-ATAPort/SATA-LPM
Microsoft-Windows-ActionQueue/Analytic
Microsoft-Windows-AltTab/Diagnostic
Microsoft-Windows-AppID/Operational
Microsoft-Windows-AppLocker/EXE and DLL
Microsoft-Windows-AppLocker/MSI and Script
Microsoft-Windows-Application Server-Applications/Admin
Microsoft-Windows-Application Server-Applications/Analytic
Microsoft-Windows-Application Server-Applications/Debug

And so on (for about 10 times as large). I’m not going to clear them by hand.

So let’s call Powershell to the rescue! (Play Thunderbirds theme song!)

First of all (and nothing to do with Powershell): wevtutil

We’re going to use this tool to display every available event source on this machine:

wevtutil el

The help states:

el | enum-logs          List log names.

Good, that’s what we need. Next up, we pass every line of this list to a command using a pipe and the Powershell Foreach-Object cmdlet

wevtutil el | Foreach-Object { … commands go here … }

The commands are going to be

wevtutil cl “$_”

The help states:

cl | clear-log          Clear a log.

And $_ is the current variable in the enumeration of Foreach-Object. I added the quotes since there are event sources with spaces and we need to have the full name in order to have wevtutil to be able to clear that log.

Now let’s add some diagnostics output to see which one we’re currently clearing:

wevtutil el | Foreach-Object {Write-Host "Clearing $_"; wevtutil cl "$_"}

Now just run it through Powershell, and bam, a clean event log.

Result

Cheers!

MSDN downloading on Vista

Let’s say you are one of the gifted persons to have MSDN access.

Let’s say you use Vista 64-bit (I don’t know if the problem occurs on 32-bit).

Let’s say you want to download something from MSDN with Microsoft File Transfer Manager.

And it does not work.

Well use this workaround:

First: download the File Transfer Manager from here.

Download and install the MSI. The default path is c:\Program Files (x86)\Microsoft File Transfer Manager”. Remember this.

Then use Firefox to go to the MSDN website, start a download, and it will prompt you to do something with the default.aspx. Well open that file with the File Transfer Manager. And it works!

Woei!

Visual Studio 2008: run as Administrator + touchpad trouble

Ik heb net gemerkt dat als men Visual Studio 2008 opent als Administrator (voor het aanmaken van de website bij IIS) de scrolling functie van mijn Synaptics touchpad niet werkt. Hij heeft er dus geen toegang tot.

Synaptics Touchad enhancer openen als Administrator helpt, maar daar moet je dan een geplande taak van maken, anders doet UAC iedere keer moeilijk.

-Kristof out

Vista: Handige tweak voor UAC

Dit is een tweak voor Vista UAC, die het ‘less annoying’ moet maken.

Ik zeg er wel bij: dit verwijderd een extra beveiligingslaag. Het feit dat het beeld zwart wordt als je een UAC prompt krijgt, is om ervoor te zorgen dat externe applicaties geen events kunnen sturen naar het UAC venster.

Door deze optie te disablen kan dat dus wel. Wees gewaarschuwd!

Hoe?

Zo:

Start -> Run, en “gpedit.msc” intikken (zonder quotes)

Dan krijg je het volgende venster:

Dus: “Computer Configuration” > “Windows Settings” > “Security Settings” > “Local Policies” > “Security Options” > “User Account Control: Switch to the secure desktop when prompting for elevation” > Dubbelklikken en dan op “disabled” zetten.

Good luck ;)

-Kristof out.

Vista: Zip disablen

Hier een handige regkey voor Zip preview in Vista te verwijderen. Handig als je bijvoorbeeld Winrar gebruikt.

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}]
[-HKEY_CLASSES_ROOT\CLSID\{0CD7A5C0-9F37-11CE-AE65-08002B2E1262}]

Wel even herstarten ;)

-Kristof out.

Vista: verbose tweak (meer opstartinfo)

Een simpele manier om Vista u te laten tonen wat er gebeurt bij het opstarten en afsluiten is dit:

Start -> Run, en “gpedit.msc” intikken (zonder quotes)

Dan krijgt ge het volgende venster:

Dus: “Computer Configuration” > “Administrative Templates” > “System” > “Verbose vs normal status messages” (dubbelklik hierop) > op “Enable” zetten, en dan uw computer opnieuw opstarten.

-Kristof out.