Solved

Home Drive not mapping

Posted on 2014-09-19
13
981 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
[X]
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
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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

705 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