I’m looking to replace our Bulk AD create VB script with PowerShell. With VBS we can create users home drives and assign permissions.

I’m very new to PS and have been looking around at comands and syntax but I can’t seem to find what I need. Anyone know of a way to add the Home drive path to a user during a PS creation. So far this is what i’m working with…

I would like to add to this to create the users home drive with something like \server\home$%username% and if possible also add the logon script info…

Foreach ($User in $UserInformation){

$CN = $User.samAccountName

$SN = $User.Surname

$Given = $User.givenName

$samAccountName = $User.samAccountName

$Display = $User.DisplayName

$User = $UserPath.Create(“User”,“CN=$CN”)

Write-Host “Creating User: $User.samAccountName”

$User.Put(“samAccountName”,$samAccountName)

$User.Put(“sn”,$SN)

$User.Put(“givenName”,$Given)

$User.Put(“displayName”,$Display)

$User.Put(“mail”,“$samAccountName@$domain”)

$User.Put(“userPrincipalName”,“$samAccountName@$domain”)

$User.SetInfo()

$Pwrd = $User.Password

$User.psbase.invoke(“setPassword”,$Pwrd)

$User.psbase.invokeSet(“AccountDisabled”,$False)

$User.psbase.CommitChanges()

3 Spice ups

I’d suggest taking a look at Quest’s Active Roles cmd-let. It is really powerful and lets you do some things with the AD so much more easily. For an example I use this script every 5 weeks to create our 100-150 new student users.

As far as the user profile path I had that in my script for a little while, unfortunately while it would populate the field with the information it would not actually create the user directory until I had opened the users account properties and reclosed it. I never had the time to chase that one down. Instead I just created all of my users into a temporary OU, then selected them all and set the profile path in the properties for the selection.