I work for a school district and I recently moved every staff member's user folder to a new file server. So the file structure looks like this:
E:
staff
asmith
bconlon
crichards
fgrant
Since every user is assigned a home directory via Active Directory, I used the following PowerShell script to remap everyone's home drive in one fell swoop:
Get-ADUser -Filter * -SearchBase 'OU=BES,OU=BPS,DC=bourne,DC=k12,DC=ma,DC=us' | ForEach-Object {
Set-ADUser $_.SamAccountName -HomeDrive "H:" -HomeDirectory "\\bpsfile\staff\$($_.SamAccountName)"
}
This worked great. However, my problem now is with the permissions. The owner of every directory in the entire tree is administrator and none of the users can write to their own directories now.
I was wondering if there's a similar way to use PowerShell to find the name of each folder in the tree (which is based on the same usernames in AD, i.e. jsmith) and then grant all permissions to that username to that folder and all of its child folders.
Thanks for any insight!
PS The file server is Windows Server 2008 R2 Standard