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?

4

If $UserName is the username, then:

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

Should do it.

  • Perfect! Thank you for helping the novice powershell user! – Cold T Jun 6 '13 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.