Solved

VBS to delete old profiles

Posted on 2008-10-23
13
2,360 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
Comment Utility
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
Comment Utility
what about if the profiles are stored on a different volume? like with roaming profiles?
0
 

Author Comment

by:BalchBingham
Comment Utility
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
Comment Utility
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
Comment Utility
no but i do so i wondered if it could help me
0
 
LVL 18

Expert Comment

by:exx1976
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 4

Expert Comment

by:futurefiles
Comment Utility
thought so, thanks
0
 

Author Comment

by:BalchBingham
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Excellent, exactly the information I was looking for.  Thank you!!
0
 

Author Closing Comment

by:BalchBingham
Comment Utility
Thanks for all your help!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

772 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

12 Experts available now in Live!

Get 1:1 Help Now