4

In attempts to automate a few things, I've come across a stumbling block with an import script for AD.

A part of the script contains:

New-ADUser -Name $Name –GivenName $Person.givenName –Surname $Person.sn –DisplayName $Name –SamAccountName $Username -HomeDrive "H:" -HomeDirectory $HDrive

The issue here is the -HomeDirectory $HDrive.

The variable $HDrive="\data\Staff Homedrives\"

How can i add %username% to the end of the HomeDirectory path?

Cold T
  • 2,391
  • 2
  • 16
  • 28

1 Answers1

4

If $UserName is the username, then:

$Hdrive = "\data\Staff Homedrives\$UserName"

Should do it.

MDMarra
  • 100,183
  • 32
  • 195
  • 326