Cleaning up

Who doesn’t love cleaning up old files, don’t worry, Powershell comes to the rescue.

We all know that shared network drives collect all kind of garbage, and usually around 90% could actually be missed.

I’ve recently been working on cleaning up files which were created a long time ago, thanks to Powershell, we can script this action and make Powershell work for us.

What I do here is to look at the creation date of the files and delete them if they are older than 2 years old, so we set a limit to target only those who are old enough to be removed.

I recommend having backup of the files before running these Powershell scripts.

Logging the output is also recommending


By |2018-08-09T22:30:51+00:00August 9th, 2018|Common, File|0 Comments

Always check first

As a System Administrator I’m always looking for automation and easier or faster ways to do my job properly. When I’m creating scripts which involve of creating or checking if something exists it prevents errors in output and is a nicer and cleaner way to go about doing scripts, why would you want to create something exists anyways? Writing scripts or snippets I use the command Test-Path combined with an if statement and it depends what I want to do if I’m going to use the negative “NOT”, let me give you an example.
$path = "C:\temp"
if(Test-Path -Path $path) {
 Write-Host "The path `"$path`" already exists"
} else {
 New-Item -Path $path -ItemType Directory
By |2018-08-03T00:44:33+00:00July 23rd, 2018|Common, File|0 Comments