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:
- PowerShell Scripts
- PowerShell Tutorials
- New-Object – Microsoft Docs
- Using the Get-ChildItem Cmdlet – TechNet – Microsoft
- Using the Get-Acl Cmdlet – TechNet – Microsoft
- Set-Acl – Microsoft Docs
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
}
Summary

Article Name
Change permissions on multiple folders using PowerShell
Description
Change permissions on multiple folders using PowerShell. If you want to change permissions on multiple folders using PowerShell, then this is your solution. Stephanos Constantinou Blog - PowerShell Scripting
Author
Stephanos
Publisher Name
Stephanos Constantinou Blog
Publisher Logo

Does this work on items within folders? Items being Powerpoint presentations, Outlook items, TMP files ect.
Hello,
As the script uses -Directory parameter it performs the changes only on folders. If you want to work with both Folders and Files, then you will need to replace -Directory parameter with -Path parameter.
Thanks
Stephanos