PowerShell

PowerShell: Delete Files older than

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”.

I hope this helps you and gives you a quick PowerShell code snipped to remove files older than a specific date using PowerShell. Also check out my PowerShell snipped to copy logfiles with date and content.