I am looking to rename some home folders within AD to and card ID number for my users. i want to eliminate having to manipulate a home folder for a user when the name changes so we are going to a numbered approach. what i am looking is a script that will take the folder name and rename it to the number assigned to the user. any suggestions
-
1My suggestion would be to use Powershell, or another scripting language. – jscott Aug 01 '13 at 18:50
-
...why are your usernames changing? – voretaq7 Aug 01 '13 at 19:03
-
@voretaq7 dumb things like users being married maybe. – tony roth Aug 01 '13 at 19:11
-
If you're doing that to prevent the hassle when usernames change (like when people get married)...I'd recommend against it. Changing the home dir is an occasional hassle. Matching username to number every time you go through the fileserver is an every day hassle. – Grant Aug 01 '13 at 19:11
-
my question is how often do you need to do this? – tony roth Aug 01 '13 at 19:11
-
@tonyroth yeah - my policy on that is "I'll update your long-form email address, your login ID stays the same." - I'm mean though :) – voretaq7 Aug 01 '13 at 20:01
-
@voretaq7 same here. – tony roth Aug 01 '13 at 20:11
1 Answers
Generally I wouldn't recommend doing what you're doing.
Specifically, I would recommend NEVER changing a user's short-form username and home directory.
These are things that get embedded into the DNA of a company and environment without your even thinking about them. They pop up in all sorts of insidious ways.
- The shared folder in someone's home directory that the whole company uses
- The nightly scheduled task with a hard-coded home directory instead of %HomeDir%
- The technical support staff that knows everyone by their username
You also lose a lot by switching to numbered directories for everyone, not the least of which is humans generally work better with recognizable patterns of letters: they'll figure out Sarah Smith is \\homedirs\ssmith
, but they'll have a much harder time remembering that she's \\homedirs\758903
.
The way I handle this situation is by creating a new email alias (which is all most people care about).
If that isn't enough for a particular situation (say Sarah Smith went through a bitter divorce and now wants to be known by her maiden name Sarah Doe) the changes are infrequent enough that I don't worry about doing them manually -- particularly as it lets me account for all the places the old username/directory may have crept into the environment.
If you still want to automate this you should do as jscott suggested: Write a powershell script that reads in a two-column CSV file (username
and ID Number
) and makes the necessary changes in AD.
Bonus points for style if the ID Number is already an AD attribute and you don't have to use a CSV file as input to your script.
-
In your particular case you say you're renaming the home folders to a "card ID number" -- you should be sure that number is not sensitive before you do this. (For example at my alma mater the student ID number encoded on your card could be used for a bunch of other potentially-nefarious purposes.) – voretaq7 Aug 01 '13 at 20:28