2

Working on a script to automate the creation of new users, it works and the user shows up, but their home directory is not created.

For example I use New-ADUser to create "Joe User" with a username of "joeu" and HomeDirectory of \\\\svr-home\\home\\%username%

Normally when you enter this same string directly into the AD during the creation of a new user, when the OK button is clicked the %username% part is automatically replaced by "joeu" and a folder is created at \\\\svr-home\\home\\joeu with all the appropriate permissions.

When I check on the account in AD, the script has set the value for the 'Home Folder' field, but the AD variable is never completed and the matching folder is not created.

If I manually edit the user in AD and click the Apply button, the home path is resolved and the folder is created. Is there a way I can force AD to execute this step?

Or do I have to manually create the home folder and set its permission and then use the actual path information for the -HomeDirectory parameter to solve this?

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Peter Bako
  • 93
  • 2
  • 7

1 Answers1

4

The code for the GUI creates the folder. When modifying the AD-attribute manually (using ex PowerShell), you have to create the folder manually and assign permissions to the user.

See https://stackoverflow.com/a/14894574/702944 for example on how to create folder and assign permissions.

Community
  • 1
  • 1
Frode F.
  • 52,376
  • 9
  • 98
  • 114