Monthly Archive


Setting a users home directory

One task when creating a new user is to set their home directory. This information is on the Profile tab in the lower box.

In the GUI we would use the Connect radio button, select a drive letter and supply the UNC path to a share.  In PowerShell we do this

$ou = "OU=BlogTests,DC=Manticore,DC=org"            
$name = "UserA"            
Get-ADUser -Identity $name |            
Set-ADUser -HomeDirectory "\\fileserver\$name" -HomeDrive "H:"            
"`nAD provider"            
$name = "UserB"            
$dn = "cn=$name,$ou"            
Set-ItemProperty -Path AD:\$dn  -Name homeDirectory -Value "\\fileserver\$name"  -Force            
Set-ItemProperty -Path AD:\$dn  -Name homeDrive     -Value "H:"       -Force            
$name = "UserC"            
Get-QADUser -Identity $name |            
Set-QADUser -HomeDirectory "\\fileserver\$name" -HomeDrive "H:"            
$name = "UserD"            
$dn = "cn=$name,$ou"            
$user = [adsi]"LDAP://$dn"            
$user.homeDirectory = "\\fileserver\$name"            
$user.homeDrive = "H:"            


The cmdlets supply parameters for HomeDirectory and HomeDrive – both fairly obvious

In the provider we have a couple of calls to Set-Itemproperty. The attribute names are self explanatory. The script is similar in that we get a directory entry for the user and set the appropriate attributes.

One Response to Setting a users home directory

Leave a Reply