Scripts Thread, User Home folders in Coding and Web Development; I've recently had a clean up of our active directory and found nearly 900 user accounts that haven't logged in, ...
26th January 2009, 06:07 PM #1
User Home folders
I've recently had a clean up of our active directory and found nearly 900 user accounts that haven't logged in, in the past 6 months.
What i'm wanting to do is to remove (move them to an external NAS unit!) all the home folders that are associated with these users, but i don't fancy shifting through 900 folders manually
anyone got any recommendations
26th January 2009, 06:30 PM #2
Without sitting down and actually writing the script, I would recommend that you disable all the unused accounts and then have a script that reads the relevant homedrive variable from AD for all the disabled accounts. If a drive exists, it should move it.
26th January 2009, 06:30 PM #3
I was looking for this a couple of weeks ago..
This is hidden on here somewhere... Orphaned Files Finder
26th January 2009, 07:04 PM #4
i should of mentioned in my first post we don't use the 'Home Folder' Local Path under the Profile Tab on AD to map our drives we have a logon.vbs script that runs and in the script there is a few lines that say
If Not MapDrive("H:", "\\fileserverone\h-" & strUser) Then
MsgBox "Unable to Map H: to userarea"
26th January 2009, 07:48 PM #5
- Rep Power
From memory when i was on my MCSA course there was a warning that the time since login isnt accurate unless you have a certain feature activated in the group policy.
Originally Posted by DanW
Id have a look and see before doing it if its true or not.
26th January 2009, 07:54 PM #6
I love it when people go out of their way to make life difficult :-)
Originally Posted by DanW
Have you got a list of the users that you're working on? If so, a quick fix is to load that into Excel - you'll get a list in Column A (eg)
In column B you put something like:
and in column C put:
="robocopy \\fileserver1\h-" & A1 & " \\nasbox\backup\" & A1 & " /move /s /r:1 /w:1 /b"
Fill down columns B and C and you'll get 2 long sets of commands. copy and paste each column into notepad and save as a batch file.
="net share h-" &A1 & " /d"
run the 2 batch files (probably quickest to do the first on the server; the second must be run on the server) and they will move all the files and then delete the shares.
You also need to delete the empty folders - assuming the shared folders are all on the same drive that's easy (another Excel column). If they're not then it's a bit more work!
If you were using a script to find the accounts to expire then you could just add something to that to do the move - if you've got a line which gets the username then something like this:
sCmd="robocopy \\fileserver1\h-" & sUser & " \\nasbox\backup\" & sUser & " /move /s /r:1 /w:1 /b"
26th January 2009, 08:48 PM #7
You have to check time since last login across all DC's
26th January 2009, 09:48 PM #8
@DanW: You could always do it the 'normal' way. I assume strUser is the user's username so you just need to bulk select the users and add \\fileserver1\h-%username% into the field.
In fact... ignoring that, if all the users' folders are in the same place then you don't need to interrogate the AD properties - it would just be <path to home folders>\h-<username>
26th January 2009, 09:55 PM #9
If it's a Windows 2003 network then this is no longer necessary; lastlogontimestamp is replicated across all DCs
Originally Posted by plexer
26th January 2009, 11:01 PM #10
thanks for all the answers guys i'll have a play in the morning
By theeldergeek in forum Wireless Networks
Last Post: 21st January 2009, 05:50 PM
By johnnyTechy in forum Hardware
Last Post: 12th January 2009, 06:05 PM
By linkazoid in forum Windows
Last Post: 7th August 2008, 02:49 PM
By timbo343 in forum Virtual Learning Platforms
Last Post: 15th July 2008, 04:38 PM
By Zoom7000 in forum Windows
Last Post: 5th December 2007, 11:33 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)