Home Drive not mapping

Posted on 2014-09-19
Medium Priority
Last Modified: 2014-10-12
We have a script that runs that creates new users, this script also creates their mailbox and does it from a csv file that is created by filling in a form.

It seems like when we create a user and give them a home drive/directory this shows within AD but does not map on logon, and when you run the set command it truncates it from \\server\userhome\%username% to \\server\userhome (the user only has permission at \\server\userhome\%username%, this works if we manually create the account but does not work if you script it.

the script that creates the user and does the ad bits (not exchange).  (see attached)

our estate is both xp and windows 7 (mid upgrade) and it does not map on either, there is no deletion of old drives at current.

Question by:Nytram
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 40333294
Try this:
$username in your code can be blank so is the reason.
$username = "$([Environment]::UserName)"

new-aduser -path "OU=New Accounts,OU=NewUsers (Unused Accounts),OU=Users,OU=organisation,DC=company,DC=co,DC=uk" -samaccountname $username -Name "$firstname $lastname" -givenname $firstname -surname $lastname -enabled $true -userprincipalname $upn -displayname "$firstname $lastname" -scriptpath "logon" -accountpassword (convertto-securestring $password -asplaintext -force) -ChangePasswordAtLogon $True -profilepath "\\stanmore\users\$username\newxp" -HomeDrive "H" -HomeDirectory "\\stanmore\userhome\$username" -otherattributes @{'extensionAttribute10' =$a10} -manager $manager -company $a10 -Department "$directorate - $department" -Description "Employment Type $employmenttype, Requested By $requestedby, Request ID $requestid" -Officephone $phone -MobilePhone $mobile -office $office -AccountExpirationDate $expirationdate -Title $title

Open in new window

LVL 14

Expert Comment

by:Justin Yeung
ID: 40334632
I can't give you an answer until see the full script, I am pretty sure you have more beside just the line.

Raheman, it is not only $username is not specificed, all other are not as well $firstname $lastname $upn and so.

and also if you use $env:Username for this command, it will just create the path with the user who ever ran this.

how can the user create a new ad user without having an account?

Author Comment

ID: 40336141
Justin, here is the whole script, it reads from a CSV which has all the fields filled in, the script creates the user just fine, and fills the home directory field in, when the user logs in, the user does not get a mapped drive but works for folder redirection

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

LVL 14

Expert Comment

by:Justin Yeung
ID: 40336384
You meant it has a home directory field in Ad profile but not mapping the home drive H:?

Or it doesn't map other drive that should be from the logon script?

Author Comment

ID: 40336438
The home directory field is populated as is the drive to connect within AD, it does not map when we log into the accounts that are created, the drives that are mapped by the logon script are all mapped correctly, nothing in the logon script references a H drive.
LVL 14

Expert Comment

by:Justin Yeung
ID: 40336569
Question 1.
It seems like when we create a user and give them a home drive/directory this shows within AD but does not map on logon

Do you have more than 1 domain controller in your company? does it take time for the replication?
you script doesn't specific which domain controller to create the user

Question 2
and when you run the set command it truncates it from \\server\userhome\%username% to \\server\userhome (the user only has permission at \\server\userhome\%username%, this works if we manually create the account but does not work if you script it.

what do you mean by running the set command? is that you tried to run the command manually with %username% on your powershelll command?

Author Comment

ID: 40336628
We have 3 DC's, the replication is very quick here, and the creation script is done overnight and the created users often don't log in for a couple/3 days.

if you log into an account (we created a test account) to test this and go to cmd and type in set, the information brought up from the command the home homeshare is truncated to \\server\userhome and the homepath is \documents and settings\username whereas when we run it on a user that was created manually it the homepath is \ and the homeshare is \\server\userhome\username
LVL 14

Expert Comment

by:Justin Yeung
ID: 40344173
so from my understanding, when you place the path on to the profile path, It will not create the folder structure for you.
another word the folder doesn't exist...... however homedirectory does......

let me know if that's the case.

Author Comment

ID: 40344324
The folder creates perfectly, we can browse to it, we use folder redirection for our my documents folder, this writes to the correct location, the drive however does not map
LVL 14

Expert Comment

by:Justin Yeung
ID: 40355659
when you run the script to create the user, does the folder created automatically?

I don't see that in your script with that function.

it doesn't matter on folder redirection, it should still show up as my documents and just the path is redirected.

the profile path is the actual path of the user
when you do echo %profilepath% that is what it should come up but not c:\users\xxx\

did you try to create a brand new user and see if any folder created automatically under the profile path?

Author Comment

ID: 40356784
AD automatically creates the folder for us, the folder exists and you can browse to this, the issue we are having is that it is that the when the user logs in, their home drive does not map as a drive as it normally would if you created the user automatically, all folders are created as they would normally be

Accepted Solution

Nytram earned 0 total points
ID: 40367802
This is now resolved,

There were two seperate issues, these were a missing : after the H in the -homedrive part of new-aduser, and permissions were not inheriting properly from our file server and so this has no been resolved with set-acl

Author Closing Comment

ID: 40375494
I found a missing : when comparing a script created user and my normal user, then i found a permission issue which is also now resolved

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question