skip to Main Content
1-800-987-654 admin@totalwptheme.com

Delete all log files of windows (Server or Not)

There was a script wich i using it from a long time… today i figure out with PowerShell its litlle more easy then my oldskool command.

 

old one was

for /F "tokens=*" %1 in ('wevtutil.exe el') DO wevtutil.exe cl "%1"

 

new one.

wevtutil el | foreach { wevtutil cl $_ }

 

maybe it isnt too shot like one word but its more rememberable for me. in my old clear command  whenever i am need it,  its end with google 🙂  there was a lot of characters and i didnt like to keeo that kind of things in my mind.

 

but new one dosnt work with in classic Elevated Command Windows, its need Elevated Power shell Window.

 

if you put “start powershell ” in front of to our command then create new scheduled task to use login,  or logout  tasks with this exported task XML of windows. you will be able to do not do that querry again.

 

<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task" version="1.2">
<RegistrationInfo> <Date>2016-11-09T14:28:55.2636</Date> <Author>centi\Administrator</Author> </RegistrationInfo>
<Triggers><BootTrigger><Enabled>true</Enabled></BootTrigger></Triggers>
<Principals><Principal id=”Author><UserId>centi\Administrator</UserId><LogonType>Password</LogonType><RunLevel>HighestAvailable</RunLevel
></Principal></Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>Start powershell "wevtutil el | foreach { wevtutil cl $_ }" </Command>
</Exec>
</Actions>
</Task>

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Back To Top