+ Post New Thread
Results 1 to 10 of 10
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, ...
  1. #1
    DanW's Avatar
    Join Date
    Oct 2007
    Posts
    246
    Thank Post
    35
    Thanked 12 Times in 12 Posts
    Rep Power
    19

    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

    Dan

  2. #2

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    Boston, MA
    Posts
    7,601
    Thank Post
    110
    Thanked 771 Times in 599 Posts
    Rep Power
    183
    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.

  3. #3
    linkazoid's Avatar
    Join Date
    May 2007
    Location
    London
    Posts
    660
    Thank Post
    125
    Thanked 90 Times in 74 Posts
    Rep Power
    79
    I was looking for this a couple of weeks ago..

    This is hidden on here somewhere... Orphaned Files Finder

    Mike

  4. #4
    DanW's Avatar
    Join Date
    Oct 2007
    Posts
    246
    Thank Post
    35
    Thanked 12 Times in 12 Posts
    Rep Power
    19
    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

  5. #5
    pagelad's Avatar
    Join Date
    Dec 2008
    Location
    Newcastle
    Posts
    181
    Thank Post
    4
    Thanked 15 Times in 13 Posts
    Rep Power
    15
    Quote Originally Posted by DanW View Post
    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
    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.

    Id have a look and see before doing it if its true or not.

  6. #6

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125
    Quote Originally Posted by DanW View Post
    i should have 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
    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:
    Code:
    ="robocopy \\fileserver1\h-" & A1 & " \\nasbox\backup\" & A1 & " /move /s /r:1 /w:1 /b"
    and in column C put:
    Code:
    ="net share h-" &A1 & " /d"
    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.

    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

  7. #7

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,689
    Thank Post
    756
    Thanked 1,715 Times in 1,526 Posts
    Rep Power
    438
    You have to check time since last login across all DC's

    Ben

  8. #8

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    Boston, MA
    Posts
    7,601
    Thank Post
    110
    Thanked 771 Times in 599 Posts
    Rep Power
    183
    @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>

  9. #9

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125
    Quote Originally Posted by plexer View Post
    You have to check time since last login across all DC's

    Ben
    If it's a Windows 2003 network then this is no longer necessary; lastlogontimestamp is replicated across all DCs

  10. #10
    DanW's Avatar
    Join Date
    Oct 2007
    Posts
    246
    Thank Post
    35
    Thanked 12 Times in 12 Posts
    Rep Power
    19
    thanks for all the answers guys i'll have a play in the morning



SHARE:
+ Post New Thread

Similar Threads

  1. Random all users home folders available!
    By theeldergeek in forum Wireless Networks
    Replies: 5
    Last Post: 21st January 2009, 05:50 PM
  2. Should I use iSCSI for home folders?
    By johnnyTechy in forum Hardware
    Replies: 4
    Last Post: 12th January 2009, 06:05 PM
  3. Moving Staff Home Folders
    By linkazoid in forum Windows
    Replies: 21
    Last Post: 7th August 2008, 02:49 PM
  4. Moodle: Users home folders
    By timbo343 in forum Virtual Learning Platforms
    Replies: 15
    Last Post: 15th July 2008, 04:38 PM
  5. Resetting Permissions for Student Home Folders
    By Zoom7000 in forum Windows
    Replies: 11
    Last Post: 5th December 2007, 11:33 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •