If you are windows based this powershell script will get a list of all folders in your users share and add the following permissions
Domain administrators - Full
Local Admins = Full
System = Full
User = Modify
Change the path and domain accordingly.
Code:
## Script to set permisions on folders in a directory where
## folder name is same as users SAMAccounName
$path = "d:\users" #edit as necessary to reflect path where folders are located
$shortdom = "somedomain" #enter your domain name
#Variables
$FC = "FullControl"
$Mod = "Modify"
$domAdmin = $shortdom + "\domain admins"
$locadmin = "builtin\Administrators"
$sys = "NT Authority\System"
#Search directory for folders
$items = get-childitem -path $path
#For each item found
$items | ForEach-Object {
#only perform on directories
if ($_.mode -match "d"){
$folder = $path + "\" + $_
$user = $Shortdom + "\" + $_
$acl = Get-Acl $folder
if ($acl.AreAccessRulesProtected) { $acl.Access | % {$acl.purgeaccessrules($_.IdentityReference)} }
else {
$isProtected = $true
$preserveInheritance = $false
$acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
}
#Set permissions routine
$inheritance=[System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit"
$propagation=[System.Security.AccessControl.PropagationFlags]::None
$allowdeny=[System.Security.AccessControl.AccessControlType]::Allow
$account1 = $domadmin
$rights1=[System.Security.AccessControl.FileSystemRights]::$FC
$dirACE1=New-Object System.Security.AccessControl.FileSystemAccessRule ($account1,$rights1,$inheritance,$propagation,$allowdeny)
$ACL.AddAccessRule($dirACE1)
$account2 = $locadmin
$rights2=[System.Security.AccessControl.FileSystemRights]::$FC
$dirACE2=New-Object System.Security.AccessControl.FileSystemAccessRule ($account2,$rights2,$inheritance,$propagation,$allowdeny)
$ACL.AddAccessRule($dirACE2)
$account3 = $sys
$rights3=[System.Security.AccessControl.FileSystemRights]::$FC
$dirACE3=New-Object System.Security.AccessControl.FileSystemAccessRule ($account3,$rights3,$inheritance,$propagation,$allowdeny)
$ACL.AddAccessRule($dirACE3)
$account4 = $user
$rights4=[System.Security.AccessControl.FileSystemRights]::$Mod
$dirACE4=New-Object System.Security.AccessControl.FileSystemAccessRule ($account4,$rights4,$inheritance,$propagation,$allowdeny)
$ACL.AddAccessRule($dirACE4)
$acl.setowner([System.Security.Principal.NTAccount] “Administrators”) #Sets the folder owner
Set-Acl -aclobject $ACL -Path $folder #write permissions to folder
}
}