• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Stephanos Constantinou Blog

PowerShell Scripting

  • Home
  • Blogs
    • PowerShell Tutorials
    • PowerShell Scripts
    • PowerShell Modules
      • Modules Cmdlets
    • Software Reviews
  • About
  • Contact
You are here: Home / PowerShell Scripts / Change permissions on multiple folders using PowerShell

Change permissions on multiple folders using PowerShell

22/12/2017 by Stephanos 2 Comments

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
Change permissions on multiple folders using PowerShell
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
Stephanos Constantinou Blog

Filed Under: PowerShell Scripts Tagged With: Comparison Operators, Get-Acl, Get-ChildItem, New-Object, PowerShell ForEach, Set-Acl

Reader Interactions

Comments

  1. bretuc12 says

    16/11/2018 at 04:48

    Does this work on items within folders? Items being Powerpoint presentations, Outlook items, TMP files ect.

    Reply
    • Stephanos says

      16/11/2018 at 08:49

      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

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Footer

Recent Posts

  • ICS Cube Product Review 26/04/2019
  • PowerShell Module SysInfo v1.2.0 15/03/2019
  • PowerShell Module SysInfo v1.1.2 13/11/2018
  • PowerShell Module SysInfo 24/10/2018
  • Get-VoltageProbe 24/10/2018
  • Get-VideoController 24/10/2018
  • Get-USBController 24/10/2018
  • Get-TrackPoint 24/10/2018
  • Get-TrackBall 24/10/2018
  • Get-TouchScreen 24/10/2018
Planet PowerShell

Categories

  • Modules Cmdlets (57)
  • PowerShell Modules (5)
  • PowerShell Scripts (38)
  • PowerShell Tutorials (35)
  • Software Reviews (2)

Archives

  • April 2019 (1)
  • March 2019 (1)
  • November 2018 (1)
  • October 2018 (56)
  • September 2018 (13)
  • August 2018 (9)
  • July 2018 (6)
  • June 2018 (8)
  • May 2018 (7)
  • April 2018 (9)
  • March 2018 (4)
  • February 2018 (6)
  • January 2018 (12)
  • December 2017 (4)
Top 10 PowerShell 2018

Blogroll

  • Planet PowerShell
  • Reddit – PowerShell
  • PowerShell Magazine
  • PowerShell.org
  • PowerShell Team Blog
  • Hey, Scripting Guy! Blog
  • Mike F Robbins
  • PowerShell Explained with Kevin Marquette
  • Mike Kanakos – Network Admin
  • The Lonely Administrator
  • AskME4Tech
PowerShell Blogs Sysadmin Blogs Banners for Top 20 Programming Blogs

© 2023 · Stephanos Constantinou Blog

  • Home
  • Blogs
  • About
  • Contact