Local Or Remote Disk Clean With PowerShell

Local Or Remote Disk Clean With PowerShell

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:

Help.
Although it is easy to understand I have included comment based help.
Individual Tasks.
The tasks are able to run independent of each other.
Custom Removal.
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.