I need to re-set users home folders in bulk to re-apply their folder permissions (the folders already exist). This works when I do it 1 by 1, manually but when I use the following script it only sets the h drive but no permissions so the user can't access the folder. Any ideas?
Get-ADUser -Filter * -SearchBase “ou=myOU,ou=myOU,dc=myDC,dc=myDC” | Foreach-Object{
$sam = $_.SamAccountName
Set-ADuser -Identity $_ -HomeDrive "H:" -HomeDirectory "\\myserver\home$\myfolder\$sam" }
Thanks in advance