Solved

Disk Cleanup for all user profiles on Terminal Server - Windows 2008

Posted on 2011-02-22
6
3,758 Views
Last Modified: 2012-05-11
I would like to be able to empty all temp directories for all user profiles on our Terminal Server which is running Windows 2008 R2. How do I action this? When I run disk cleanup as the Administrator it only relates to the Administrator profile. I would really like perform some sort of disk cleanup that will affect all the profiles on the Terminal Server.

Any ideas?

Thank you
0
Comment
Question by:the_omnific
  • 4
6 Comments
 
LVL 9

Expert Comment

by:Lester_Clayton
ID: 34950801
There is no single command or folder you can erase to do all profiles on Terminal Servers.  What you'd have to do is list all the folders in the users area, and then systematically remove all temp folders for each directory.

Example : Dir list of C:\Users reveals 5 users named User1, User2, User3, User4, User5

Then, you'd delete the contents of the 5 following folders.

C:\Users\User1\AppData\Local\Temp\4
C:\Users\User2\AppData\Local\Temp\4
C:\Users\User3\AppData\Local\Temp\4
C:\Users\User4\AppData\Local\Temp\4
C:\Users\User5\AppData\Local\Temp\4

Be careful though - If this folder is missing, it will cause issues - only delete the contents of the folders, not the folders themselves.
0
 
LVL 12

Expert Comment

by:prashanthd
ID: 34951252
Hi,

You can try this code
On Error Resume Next
    
    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder("c:\users\")
    Set fc = f.SubFolders
    
    For Each f1 in fc
        temp_path="c:\users\"& f1.Name &"\AppData\Local\Temp\4\*.*"
        fso.DeleteFile temp_path, True 
    Next

Open in new window

0
 
LVL 1

Author Comment

by:the_omnific
ID: 34955324
prashanthd

Please find attached
vberror.jpg
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 1

Author Comment

by:the_omnific
ID: 34955358
Lester_Clayton > You mean don't delete the temp folder itself C:\Users\User1\AppData\Local\Temp but we can delete everything inside it including subfolders without causing issues ?
0
 
LVL 1

Accepted Solution

by:
the_omnific earned 0 total points
ID: 34956141
Thank you for your input guys but I have opted to use CCleaner to run in silent mode in everyone's start-up.
0
 
LVL 1

Author Closing Comment

by:the_omnific
ID: 34990875
I have used a different method that I am happy with.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OfficeMate Freezes on login or does not load after login credentials are input.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question