Disk Cleanup Script for Multiple Servers

is there any script available or can be prepared to automate disk cleanup stuff ? Generaly what we cleanup to freeup some disk space of OS drive.? following are the items I could recollect.

1. temp folder
2. %temp% folder
3.  unknown profiles or profiles which have not logged in since last 2 months (DelProf 2.exe)
4. dmp files
5. ISO images from user's profiles (desktop or document folders) or any files which are bigger in size.
6. anything else ??
LVL 1
Affaan AbyazAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mal OsborneAlpha GeekCommented:
Log files.

Usually C:\inetpub\logs and C:\Windows\System32\LogFiles

Often there is a heap of old stuff with no useful purpose taking up space.
0
Mal OsborneAlpha GeekCommented:
Also old .OST and .PST files, from reconfigured email accounts. These can be huge.
0
Affaan AbyazAuthor Commented:
Makes Sense.. OST & PST would be exceptional in my case as I am looking for only servers.
0
Muhammad BurhanManager I.T.Commented:
try this

$objShell = New-Object -ComObject Shell.Application 
$objFolder = $objShell.Namespace(0xA) 
$temp = get-ChildItem "env:\TEMP" 
$temp2 = $temp.Value 
$WinTemp = "c:\Windows\Temp\*"

Remove-Item -Recurse  "$temp2\*" -Force -Verbose
$objFolder.items() | %{ remove-item $_.path -Recurse -Confirm:$false}
Remove-Item -Recurse $WinTemp -Force

cleanmgr /sagerun:1 | out-Null
$([char]7) 
Sleep 1  
$([char]7) 
Sleep 1

Open in new window

you can add variables for application's temp folder like
$temp3=C:\Program Files\IDM\Temp\*
Remove-Item -Recurse $temp3 -Force
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.