I came across an interesting script on Reddit /r/PowerShell recently. It was an answer to a request for a remote disk clean script that could run across a network. Looking at the code I decided the script could do with a little tidy up and rewrite.
If you look at the original code you will find it is environment specific. Some of it has poor design and does not inspire confidence:
$temp = get-ChildItem "env:TEMP"
$temp2 = $temp.Value
I completely rewrote the script using the original as a basis for the tasks to perform. It now includes:
Although it is easy to understand I have included comment based help.
The tasks are able to run independent of each other.
You can now remove a custom list of files or folders.
This isn’t a script that’s needed every day. But it is an easy way to perform a disk clean.
Find the full script on Github.