Change permissions on multiple folders using PowerShell

Scenario:

Change permissions on multiple folders using PowerShell.

I needed to add permissions to a specific group of users on all folders under a specific directory. The problem that I had to overcome was that the inheritance was blocked and I was not able to change the root and inherit the permissions. After some research, I wrote the below script to change permissions on multiple folders under a specific directory. I have saved a lot of time not to go manually and add the permission to each folder. The number of folders was over 200.

Related Links:

Solution / Script:

$StartingPath = "F:\rootfolder" $Right = "FullControl" $Principal = "domain\admins-group" $Rule = New-Object System.Security.AccessControl.FileSystemAccessRule($Principal,$Right,"Allow") foreach ($Folder in $(Get-ChildItem -Directory $StartingPath -Recurse)) { $Acl=Get-Acl $Folder.FullName $Acl.SetAccessRule($Rule) Set-Acl $folder.Fullname $Acl }