Automated file deletion #01


new-psdrive -name SomeFolder -psprovider FileSystem -root \\SomeShare\SomeFolder
$drive = new-object -com
$drive.MapNetworkDrive(“x:”, “\\SomeShare\SomeFolder”)

$EnumerateOpen = Get-ChildItem o:\ -recurse -include .DS_Store -force
foreach($FileName in $EnumerateOpen)

remove-psdrive -name SomeFolder



As with my previous post, this script does nothing apart from delete irritating files that do nothing apart from waste space. In this case, it’s the lovely .DS_Store files that Mac OS X throws around with glee. I’ve got a feeling you can put loads of file types in one script, but I’ve got a script per file type to (a) make testing easier- didn’t want to risk accidentally wiping out more than I’d intended and (b) to make it easier for others to follow.

Remeber that although your .DS_Store is “only” 7KB in size, it’s probably taking up way more space than that because file systems have minimum block sizes. According to this link-– any Windows OS from the last 12 years will default to a minimum block size of 4KB, so that 7KB file is already wasting 1KB of space. Multiply that by the number of .DS_Store files lying around and that’s a lot of wasted space. Add in all those accidentally created .lnk files, thumbs.db etc- just bin ’em.


The case of the vanishing disk space

Disk space seems to vanish more and more these days. Our new TMG web filtering box has just been gobbling the stuff up. Checked all the usual culprits first- ran “cleanmgr /sagerun:65535”, deleted \windows\temp etc. Nothing- not worthwhile anyway.

Then by chance I decided to check in %programfiles%\Microsoft Forefront Threat Management Gateway\Logs. Whoa. so many .llq files. 11GB in fact. That could explain a lot. So I’m deleteing any. llq’s before today, which should sort the problem out.