2

I'm trying to create a Group Policy to map users Home Drives among others when they login. All the other drives are mapping fine, however because of the way in which the usernames are formatted, I've run into a conundrum trying to get the Home Drive Mapped.

In short, the usernames are formatted Firstname.Lastname, whereas the home folders on the server are formatted as Firstname Lastname (Note the space and not [dot])

So calling all Windows GPO Gurus - do you know of a way that I can create a GPO to map a users' Home Drive using their Name, rather than their username?

For reference, we are using Windows 7 Clients with the AD Server being Server 2008 R2.

  • Is there a reason that you're not simply using the AD attributes to map a home folder to a drive letter? – SturdyErde Aug 21 '15 at 13:05
  • We aren't redirecting users Documents etc... to their home drives on the server. Also, we would be in the same predicament, we would need to use something like %LogOnUser% for that, which won't work. Another thing is that we will be mapping multiple drives, so a GPO was the easiest and quickest option I thought. – James Aug 21 '15 at 13:11
  • Mapping a home drive and redirecting My Documents are two different things. To map the home folder to a drive, simply modify the users' AD attributes using ADUC or PowerShell. In ADUC, go to the account's Profile tab, look at the "Home Folder" section, select the Connect option, choose a drive letter, and then type the UNC of their home folder. This will be easier in PowerShell because you can script everything, using the first name and last name as variables to construct the home folder path. – SturdyErde Aug 21 '15 at 13:19
  • OK, so have you got any links that you have seen for the PowerShell command(s) that I would be looking at using for this? Thanks :) – James Aug 21 '15 at 14:14
2

Here's an example of how you can do this to a single user with a script. It's crude but it works well as an example to show the process.

$user = Get-ADUser James
$homeName = $user.GivenName + " " + $user.Surname
$user | Set-ADUser -HomeDirectory \\FileServer\Users\$homeName -HomeDrive H -Credential (Get-Credential)

Replace the UNC with your file share, and change the H drive letter to whatever drive letter you want to use for the user's home drive. Once you wrap your head around this code, your next step might be to figure out how to run it against all users at once.

  • Great, thanks very much, i'll have a look and a play about and let you know how I get on :) – James Aug 21 '15 at 15:09
  • Do you really need the Credential parameter? – iPath Aug 23 '15 at 13:56
  • Not if you have already launched your PowerShell session with an account that has Domain Admin or Account Operators permissions. Depends on how well you have pursued best practices for privileged accounts. :) – SturdyErde Aug 23 '15 at 14:02
  • You're welcome! Let us know if you have any other questions about this script. – SturdyErde Aug 26 '15 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.