Tagged: old

ACT filling up your disks?

When you have ACT (The Microsoft Application Compatibility Toolkit) running in your environment you might get disks filled up with XML-files on your ACT-server.

The logprocessor uses those files to populate the database with information. So, when those are processed you do not need them anymore. (If you have a backup of your database…)

So, I did it the easy way, scheduled a powershell command to remove files older than 7 days:

Get-ChildItem D:\ACTLogs -Recurse -Include *.xml* | where {$_.CreationTime -lt (Get-Date).AddDays(-7)} | Remove-Item

If you want a nicer look and feel to your script you can use this instead:

Get-ChildItem D:\ACTLogs -Recurse -Include *.xml* | where {$_.CreationTime -lt (Get-Date).AddDays(-7)} | Sort-Object CreationTime | ForEach-Object {
	Write-Host "Processing: " -ForegroundColor Yellow -NoNewline
	Write-Host $_.FullName -ForegroundColor White -NoNewline
	
	$span = New-TimeSpan $_.CreationTime $(get-date)
	Write-Host " $($span.Days) days old" -ForegroundColor Yellow -NoNewline

	Remove-Item $_.FullName

	Write-Host " [del]" -ForegroundColor Red
}