I have created the following script to take data from a csv and create new users in AD:
Import-Csv c:\newusers.csv | ForEach-Object -Process {New-QADUser -name $_.'un' -ParentContainer 'CN=users,DC=domain,DC=local' -SamAccountName $_.'un' -FirstName $_.'fn' -LastName $_.'ln' -description '6' -userprincipalname $_.'un' -UserPassword 'P@ssword' | Enable-QADUser | Set-QADUser -HomeDirectory '\\srv1\home\$_.un' -HomeDrive 'H:' -UserMustChangePassword $true | new-item c:\home\$_.un -type directory} Everything seems to be working except for the new-item creation of the home folders. The -homedirectory and -homedrive commands work and they are named and mapped properly in the users profile but when I try to create the actual folders on the drive it creates a folder called $_.un and then throws errors for object already exists.
I have tried c:\home\$_.un, c:\home\$_.'un', c:\home\'$_.un all with similar results. Can anyone shed some light on what is wrong with my syntax?