Tag Archives: Gallery

Collection of scripts

Recently I started contributing scripts to the community by uploading some of my scripts to the Technet Script Repository. Today I would like to highlight two of the scripts I have uploaded.

Delete files older than x-days – Cleanup Script

This script delete files older than x-days. The script is built to be used as a scheduled task, it automatically generates a logfile name based on the copy location and the current date/time. There are various levels of logging available and the script can also run in -listonly mode in which it only lists the files it would otherwise delete. There are two main routines, one to delete the files and a second routine that checks if there are any empty folders left that could be deleted.

PowerShell function to run as a different user

Script with both both the ability to set and get. When the Set switch is specified the script will prompt for credentials and write the password to the file file specified. When the script is running with the Get switch the script will read the password from the file specified in the $filename variable and use the username specified in the $username variable. This allows you to runas another identity without having to enter credentials.

For a complete listing of all scripts I have published please have a look at the Technet Gallery I have published other scripts there as well and I will be happy to answer any questions you have about them.