Skip to content

Powershell script to remove files that are older than a given date

License

Notifications You must be signed in to change notification settings

wporter82/cleanupPS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

cleanupPS

Cleans a directory of files older than a period of days.

##Options: ###filePath Location that the cleanup will be done. Default: E:
###limit The total size in GB that the target file path should be before cleaning is done. Default: 40 ###days How many days back files should be kept. Any file older will be deleted. Default: 365 ###logFile Location of the generated log file. Default: User's $HOME directory ###WhatIf Run without deleting any files, just show what would be deleted.

##Example: .\cleanup.ps1 -filePath E:\ -limit 40 -days 365 -logFile cleanup.log

##Usage: Download and save the file cleanup.ps1 to a safe location. Recommendation: C:\Users[username]

Create a new scheduled task by following the steps here: Schedule a task

When you are at the step to choose a program to run, use the following: powershell -file "[path to cleanup.ps1]" [options]

###Note: The default values are hard coded to fit my test system but can be modified if necessary in the script.

About

Powershell script to remove files that are older than a given date

Resources

License

Stars

Watchers

Forks

Packages

No packages published