No announcement yet.

Removing orphan home directories

  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing orphan home directories

    I need some advice/help:
    Over several years, a lot of users have been deleted, but their home directories not.

    Name of home directory is the same as active directory username.

    I do have a .txt file with all the current active usersnames on the domain and a .txt file with all the directories in the /home dir, but the two files have a different format, so they are difficult to compare.

    Is there any program/script or method that you can advice that tells me which home directories are orphan?

    I am not a good script writer/programmer.

    Thank you very much.


  • #2
    Re: Removing orphan home directories

    why not just open the folder containing the home directories and look at the modified date and time and/or last accessed time...

    sort by last accessed, then select the top folder and hold down select the last safe entry, selecting all the folders that have this date range that you would considered orphaned, and then deleting (or better yet move them to a folder you create called 'orphaned) them.

    if anyone is missing anything, you can restore the folder to the proper location without any problem.

    after a week or so and nobody is missing anything, delete them.

    it sounds simpler than scripting the job, unless you have more than 4,000 members.

    what do you think??

    its easier to beg forgiveness than ask permission.
    Give karma where karma is due...


    • #3
      Re: Removing orphan home directories

      Hi James,

      Thank you for your reply.

      That is definitely an option. By that way I can already select 482 homedirs, but it's a little bit risky, because there are users who are active, but never use their homedir or have not used their home directory for a while. I can of course make a backup, but there will be calls for sure and that may take too much time!

      I think scripting will be the only way, or maybe there is some kind of tool available for it.


      • #4
        Re: Removing orphan home directories

        Can't you just dir \home >C:\homedirs.txt and put that output in a spreadsheet to compare with your AD users - make sure both are in alphabetical order.
        For future use, make yourself a checklist of items to check when deleteing a user: mailbox, homedir and include a task to set things to a holding area to ensure they are not required for a certain period. Or consult with other members of the dept to discover if the data has to be kept or deleted. This is all about managing data in an efficient manner and les about writing scripts to deal with it.

        Steven Teiger [SBS-MVP(2003-2009)]
        Iím honoured to have been selected for the SMB 150 list for 2013. This is the third time in succession (no logo available for 2011) that I have been honoured with this award.

        We donít stop playing because we grow old, we grow old because we stop playing.


        • #5
          Re: Removing orphan home directories

          Thank you for your reply.
          I will try it that way.

          I did:

          dir /b > c:\homedirs.txt

          It's in alphabetical order.

          But I don't know how to export the AD userlist in alphabetical order and one per line.

          I tried:
          NET USERS /DOMAIN >c:\adusers.txt

          but the output of this command is not in alphabetical order and one per line.

          Does anybody know how to do that?

          Thank you!


          • #6
            Re: Removing orphan home directories

            Import list into Excel and sort it out there?
            Tom Jones
            MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
            PhD, MSc, FIAP, MIITT
            IT Trainer / Consultant
            Ossian Ltd

            ** Remember to give credit where credit is due and leave reputation points where appropriate **