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?

1 Answer 1

4

If $UserName is the username, then:

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

Should do it.

1
  • Perfect! Thank you for helping the novice powershell user! Commented Jun 6, 2013 at 12:53

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.