Tag: logfiles

Last updated by at .

Powershell: How to export Windows Eventlogs with Powershell

Powershell Header

This is a little dirty Windows Powershell script which exports or backups Windows Eventlogs. The script creates a .evt file which can be used with the Windows Eventlog Viewer.

And with the next code it cleans up older exported Eventlogs.

UPDATE: If you wanna clean the Eventlog after the export you can do that by using the Clear-Eventlog cmdlet. (Thanks to Michel from server-talk.eu)

And here the whole “script”

Powershell: Copy Logfiles with Date and Content

Powershell Header

Some days ago I made a blog post about Select-String in Powershell. I created a “script” or a better a command to check logfiles for a specitifc text and copy the logfile to another place.

Now I added also a Startdate and a Enddate for the logfiles you wanna search in.

Powershell: Delete Files older than

Powershell Header

This is a simple Powershell script which deletes Files older than some days. You can use it to cleanup old logfiles or other things. If you run the script the first time you can add the “-WhatIf” parameter after Remove-Item command.

If you need to delete files in subfolders too, you can use this script. This is the same script with the Get-Childitem parameter “-Recurse”.