granting premmission for each user in his own directory using powershell


  • i have 45 user in active directory and 45 folders that has the same name as the ad users i want to use script that give evrey user in his own directory full control on his own directory how do ido it and 
    Monday, December 26, 2016 7:47 PM

All replies

    Import-Csv C:\test\Bookv4.csv -Delimiter ";" | foreach-object {
     $Login = $_.Login
     $userfolder = $_.userfolder + $_.login 
     $ACL = Get-Acl $Userfolder
     $ACL.SetAccessRuleProtection($true, $false)
     $ACL.Access | ForEach { [Void]$ACL.RemoveAccessRule($_) }
     $ACL.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("$NTDomain\Domain Admins","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow"))) 
     $ACL.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("$NTDomain\EnterPrise Admins","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow"))) 
     $ACL.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule("$NTDomain\$login","Modify", "ContainerInherit, ObjectInherit", "None", "Allow")))
     Set-Acl $Userfolder $ACL

    Tuesday, December 27, 2016 2:15 AM
  • Maybe something like that. The script expects there is a folder already in place, named the same way as the user login, like 'c:\userfolder\user1' (don't know if it's your case), and the csv looks like this :




    And, it will apply permissions to a folder like this. Top picture is modified, other one is default.

    Best Regards,

    Jesper Vindum, Denmark

    Systems Administrator

    Help the forum: Monitor(alert) your threads and vote helpful replies or mark them as answer, if it helps solving your problem.

    Tuesday, December 27, 2016 2:18 AM
  • Hi,

    Are there any updates?

    If the replies have resolved your problem, please mark it as answer as it would be helpful to anyone who encounters the similar issue.

    Thank you.

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Friday, December 30, 2016 7:59 AM