Solved

Home Drive not mapping

Posted on 2014-09-19
13
596 Views
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.

adpartofnewusers.txt
0
Comment
Question by:Nytram
  • 7
  • 5
13 Comments
 
LVL 18

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

0
 
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?
0
 

Author Comment

by:Nytram
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

newusers.txt
0
 
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?
0
 

Author Comment

by:Nytram
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.
0
 
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?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:Nytram
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
0
 
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.
0
 

Author Comment

by:Nytram
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
0
 
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?
0
 

Author Comment

by:Nytram
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
0
 

Accepted Solution

by:
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
0
 

Author Closing Comment

by:Nytram
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
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now