1

I want my Active Directory users to have their own Home folder to store their files and I want to set this for each user account via PowerShell. I've tried several things but all it does is change the setting under "profile" in AD to the homefolder location, and this does not seem to show up for the users when they log in. Some of the code i've tried:

    SET-ADUSER inggul –HomeDrive ‘P:’ –HomeDirectory ‘\\WIN-L372AGVF8AI\NewHome\$Inggul’

$users = Get-ADUser -SearchBase "ou=sAdminOU,dc=kossi,dc=local" -Filter * -Properties Department
foreach ($user in $users)
{
Set-ADUser $_.SamAccountName -HomeDrive "Z:" -HomeDirectory "\\WIN-L372AGVF8AI\NewHome\($_.SamAccountName)"
}
1

If you have set the path and it show up in the profile but it will not map for the users, then it is most likely an access problem. It will not map the drive unless the user has access to the path. If there is a typo or if the permissions are not correct, the drive will not map. It will also not map if the network is not available at the time of login. The network unavailable issue is common with laptops that the wireless doesn't connect quickly enough.

Also note that when you create Home directories through the AD Users and Computers GUI, it will create the folder (if needed) and add the permissions explicitly for the user. If you are changing the properties through powershell, you will need to create and set permissions yourself. You can do this via powershell as well.

$samAccountName = "TUser"
$domain = "Contoso"
$homePath = "\\Server\Home"

### Create Home Folder
New-Item -Path "$homePath\$samAccountName" -ItemType Directory

### Set Permissions on home folder
$aclPath = "$homePath\$samAccountName"
$acl = Get-Acl $aclPath

$identity = "$domain\$samAccountName"
$rights = "Modify"
$inheritanceFlags = "ContainerInherit, ObjectInherit"
$propagationFlags = "None"
$accessControlType = "Allow"

$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("$identity","$rights","$inheritanceFlags","$propagationFlags","$accessControlType")

$acl.AddAccessRule($rule)

Set-Acl $aclPath $acl
  • Its all beeing tested on the same computer, so its not the internet access.. ill check all the permissions and so on next time im there, thanks :) – MartinTheNob May 6 '17 at 14:32
  • Best test is to just map it normally, maybe as a different letter. That tests all of the client side requirements. – Cory Knutson May 6 '17 at 14:34
  • No, by all means, use a GPO. I just said map manually to rule out the problems. – Cory Knutson May 6 '17 at 15:14
  • Oh, yeah. I undrestood that, but for some reason i felt like saying i prefer GPO.. Thanks for the dvice though :) – MartinTheNob May 6 '17 at 15:31
  • Teachers? Are we doing your homework? Are you allowed to use Serverfault on your exams, too? :) – Esa Jokinen May 6 '17 at 17:18

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.