Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Home Drive not mapping

Posted on 2014-09-19
13
Medium Priority
?
1,559 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 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

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
Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

 
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
 

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

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

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

Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
Welcome to 2018! Exciting things lie ahead in the world of tech. To start things off, we compiled great member articles on how to stay safe, ways to learn, and much more! Read on to start your new year right.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

572 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