Solved

VBS to delete old profiles

Posted on 2008-10-23
13
2,361 Views
Last Modified: 2013-11-10
I need a vb script that will delete all user profiles that have not been accessed within the last 90 days.  The script should exclude required profiles (Administrator, All Users, Default User, etc) but delete all older folders and files.  This script will be pushed out to 500+ machines, so it needs to be fully automated.  I've looked around and found similar scripts, but have been unable to modify them to do exactly what I need.  We do not use Roaming Profiles in our environment.  Thanks in advance!
0
Comment
Question by:BalchBingham
  • 5
  • 5
  • 3
13 Comments
 
LVL 18

Accepted Solution

by:
exx1976 earned 300 total points
ID: 22788447
Download this

http://www.microsoft.com/downloads/details.aspx?familyid=901a9b95-6063-4462-8150-360394e98e1e&displaylang=en


Then simply run


DelProf /I /D:90

That will delete every profile that hasn't been accessed in 90 days and will ignore errors.  The executable is standalone, so you can push it in a login script.

Enjoy!
0
 
LVL 4

Expert Comment

by:futurefiles
ID: 22788526
what about if the profiles are stored on a different volume? like with roaming profiles?
0
 

Author Comment

by:BalchBingham
ID: 22788653
That utility works great if I wanted to delete all profiles that haven't been used in X number of days, but I need to exclude certain admin profiles so that they are not deleted.  Is there a switch I can add to the command line?
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22788883
I have never seen it delete all users or default user.  I'm not sure about the administrator profile.

I do know that you need to either use RunAs or be logged on as an administrator in order to run it though..  ?

Perhaps give it a shot on one machine and see if it does what you want?  I've been using it for years on terminal servers and Citrix servers (in conjunction with UPHClean) to keep the drive space under control, and it works great.

@Futurefiles - he said he doesn't use roaming profiles..
0
 
LVL 4

Expert Comment

by:futurefiles
ID: 22789020
no but i do so i wondered if it could help me
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22789085
Oh.  LOL

In that case, I doubt it.  I use roaming profiles for my users, and this utility only cleans up the local copies of them.

For instance, when I was running TS, I had 500 users logging into 6 TS boxes.  Sometimes the users wouldn't log onto one of the boxes for weeks at a time (but would log onto other ones - it was an NLB group).  So every night, I ran delprof /I /D:7 to remove all the locally cached profiles that were older than 7 days.  Kept enough free space on the disk for the servers to survive longer than they otherwise would have (only had 18GB disks).  But, the roaming profiles that were centrally stored on the file server were untouched, meaning that the next time the user logged in, the profile just copied down to the TS box again.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:futurefiles
ID: 22789123
thought so, thanks
0
 

Author Comment

by:BalchBingham
ID: 22789554
You're right, it doesn't delete the Default User or All Users profile, but we have a local admin account stored locally on each computer that needs to remain so that we can log into the machine in case it falls off the domain.  Other than that, the utility does exactly what I need it to.  Thanks for your help on this.
0
 
LVL 18

Expert Comment

by:exx1976
ID: 22789705
Just because the profile is deleted doesn't mean the ACCOUNT is deleted..  Is there anything that important in the profile?  If so, perhaps just script to move those programs/shortcuts to a different directory?

0
 

Author Comment

by:BalchBingham
ID: 22789792
There's not necessarily anything important in the profile, but can you clarify what you mean about the account not being deleted?  Our purpose in cleaning out the Docs and Settings folder is because we've noticed a performance issue when more than 10 or so profiles are being stored.  In our environment, we have "floaters" that will sit at a users desktop for a week or so while the normal user is out.  So over time, we will get computers with 30+ profiles being stored locally, most of which were only accessed once and will never be touched again.
If deleting the profiles leaves the account behind, will we continue to see these performance issues?
0
 
LVL 18

Assisted Solution

by:exx1976
exx1976 earned 300 total points
ID: 22789829
I think you're confusing profile and account...


You're worried about running this utility and it deleting the local administrator's account.  It will not.  What will happen is when you login with the local administrator's account, it'll be just like the first time you logged into the computer "Creating your profile, configuring IE", all that crap.

Your "floaters", I'm assuming, have DOMAIN accounts, not LOCAL accounts.  Ergo, yes, what you are really after is to remove the profile information, not the account information.  This utility removes profile information.

0
 

Author Comment

by:BalchBingham
ID: 22789875
Excellent, exactly the information I was looking for.  Thank you!!
0
 

Author Closing Comment

by:BalchBingham
ID: 31509309
Thanks for all your help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

948 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now