Tag Archives: rotate-eventlogs

A friend of mine came to me with an interesting powershell challenge today: how can I use powershell to archive and clear event logs? Well, challenge accepted! The reason the challenge arose is due to maintenance he performs on a number of customer servers. Every month he saves each eventlog and clears it manually, a time consuming task if you have more than a few servers. So here’s what I came up with: A powershell function, Rotate-EventLogs, that exports the application, system and security logs to xml files with todays date as filename, then the logs are cleared. The function isn’t really all that advanced, it checks if the folders where the logs will be saved exists, if not it will create them. Then it will export each log to c:eventlogs<logname>%d%m%Y.xml For example the system log exported today would be located at c:eventlogssystem6092012.xml. After the export of the three eventlogs…

Read more

1/1