Adding permissions to folder using PowerShell

Powershell

Hi!
Today’s post will continue series of PowerShell tips for automation. Today’s subject is about adding permissions for user/group to the certain folder.

Here is a function to do that:

Let’s break it into the parts.

The first step is to get current security settings of the folder:

Using $Acl variable, we can check if we already have needed permissions (FullControl in our example):

 

If not, we should create a new object with a needed rule, add it to the existing rules and rewrite settings:

That’s it! 🙂

Leave a Reply