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
Dan

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.
I was looking for this a couple of weeks ago..
This is hidden on here somewhere... Orphaned Files Finder
Mike
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
Code:If Not MapDrive("H:", "\\fileserverone\h-" & strUser) Then MsgBox "Unable to Map H: to userarea" End If
Dan
I love it when people go out of their way to make life difficult :-)
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:Code:="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.Code:="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:
Code:set oShell=createobject("wscript.shell") sCmd="robocopy \\fileserver1\h-" & sUser & " \\nasbox\backup\" & sUser & " /move /s /r:1 /w:1 /b" oShell.run sCmd,,true

You have to check time since last login across all DC's
Ben

@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>
thanks for all the answers guys i'll have a play in the morning![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)