Archive

Posts Tagged ‘ACL’

Set Folder Permissions using a PowerShell script

February 13th, 2009 Niklas Goude 12 comments

A common Admin task is Setting permissions on folders for new Users or Groups. doing this manually can be pretty boring and timeconsuming. This script automates these steps through PowerShell.

The parameters that I’ve added to the script are:

  • -Path Folder to Create (Required)
  • -User User who should have access (Required)
  • -Permission Specify Permission for User, Default set to Modify (Optional)
  • -help Prints the HelpFile (Optional)

The script sets the folderpermissions for a User or a group on a folder and if the folder doesn’t exist, it creates the folder and adds the specified permissions.

Running the Script on one folder gives the user or group permissions on the folder and on child folders. If you run the script recurse, it will break the inheritance for the specified User/Group and set the permissions specified on each folder.

Here are 2 examples on running the script.


./SetFolderPermission.ps1 -path C:\User -Access APA\MyGroup -Permission Write

Get-ChildItem -path C:\User -recurse |
Where { $_.Attributes -match "d"} |
ForEach {
./SetFolderPermission.ps1 -path $_.Fullname -Access APA\MyGroup -Permission Read
}

If you want to display the HelpText simply type:


./SetFolderPermission.ps1 -help

Here’s a link to the script

Rating 3.00 out of 5
[?]