PowerShell To Set Folder Permissions

The Woo

I am trying to use the "default" options in applying folder permissions; by that, I mean that using the "Full Controll, Write, Read, etc" in the 'Properties' for a folder.

The following script works to add the user in, but it applies "Special Permissions" - not the ones with the tick boxes for the ones visible in the properties menu of the folder:

$Acl = Get-Acl "\\R9N2WRN\Share"

$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule ("user","FullControl","Allow")

$Acl.SetAccessRule($Ar)
Set-Acl "\\R9N2WRN\Share" $Acl

What am I doing wrong please?

PeterK

Specifying inheritance in the FileSystemAccessRule() constructor fixes this, as demonstrated by the modified code below (notice the two new constuctor parameters inserted between "FullControl" and "Allow").

$Acl = Get-Acl "\\R9N2WRN\Share"

$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("user", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")

$Acl.SetAccessRule($Ar)
Set-Acl "\\R9N2WRN\Share" $Acl

According to this topic

"when you create a FileSystemAccessRule the way you have, the InheritanceFlags property is set to None. In the GUI, this corresponds to an ACE with the Apply To box set to "This Folder Only", and that type of entry has to be viewed through the Advanced settings."

I have tested the modification and it works, but of course credit is due to the MVP posting the answer in that topic.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SET-ACL folder permissions not applying correctly with my PowerShell script

From Dev

PowerShell Set permissions on a folder/directory from the command line

From Dev

Wix: CustomAction to set Folder permissions

From Dev

unable to set group permissions for a folder

From Dev

How to use powershell and set-acl to replicate permissions across folder structure and for specific extensions?

From Dev

Inno Setup - How to set permissions of installation folder

From Dev

Set permissions for a folder for everyone except the owner

From Dev

I want to set the permissions of the target folder to 777

From Dev

How to set the future permissions of content in folder

From Dev

Set folder permissions to 0444 but now cannot cd in

From Dev

Set permissions on NTFS folder to control permissions on contents of newly created subfolders

From Dev

Set "Share Permissions" for a UNC path using Powershell

From Dev

Disable inheritance and manually apply permissions when creating a folder in Powershell

From Dev

Taking ownership of a folder and adding full permissions to a domain account in powershell?

From Dev

Disable inheritance and manually apply permissions when creating a folder in Powershell

From Dev

How can I add Localhost\Users + READ permissions to a folder in Powershell

From Dev

folder permissions

From Dev

How do I set permissions on a network-shared folder?

From Dev

How to set folder permissions for a particular container on Elastic Beanstalk

From Dev

WinSCP .NET assembly - How to set folder permissions after creating directory?

From Dev

How To Set Folder Permissions in Elastic Beanstalk Using YAML File?

From Dev

set read and write permissions to folder and all its parent directories

From Dev

Ubuntu Linux server - set file permissions for VirtualBox shared folder

From Dev

How do I set permissions on a network-shared folder?

From Dev

Is there a way to set permissions of a remote folder via VFS in Java?

From Dev

Do application installers set folder permissions? Or is it up to Windows?

From Dev

How do I set permissions on directory(folder) on IIS 6.0?

From Dev

Can't set permissions on Filenet P8 folder

From Dev

Use icacls.exe to set special folder permissions for a domain user

Related Related

  1. 1

    SET-ACL folder permissions not applying correctly with my PowerShell script

  2. 2

    PowerShell Set permissions on a folder/directory from the command line

  3. 3

    Wix: CustomAction to set Folder permissions

  4. 4

    unable to set group permissions for a folder

  5. 5

    How to use powershell and set-acl to replicate permissions across folder structure and for specific extensions?

  6. 6

    Inno Setup - How to set permissions of installation folder

  7. 7

    Set permissions for a folder for everyone except the owner

  8. 8

    I want to set the permissions of the target folder to 777

  9. 9

    How to set the future permissions of content in folder

  10. 10

    Set folder permissions to 0444 but now cannot cd in

  11. 11

    Set permissions on NTFS folder to control permissions on contents of newly created subfolders

  12. 12

    Set "Share Permissions" for a UNC path using Powershell

  13. 13

    Disable inheritance and manually apply permissions when creating a folder in Powershell

  14. 14

    Taking ownership of a folder and adding full permissions to a domain account in powershell?

  15. 15

    Disable inheritance and manually apply permissions when creating a folder in Powershell

  16. 16

    How can I add Localhost\Users + READ permissions to a folder in Powershell

  17. 17

    folder permissions

  18. 18

    How do I set permissions on a network-shared folder?

  19. 19

    How to set folder permissions for a particular container on Elastic Beanstalk

  20. 20

    WinSCP .NET assembly - How to set folder permissions after creating directory?

  21. 21

    How To Set Folder Permissions in Elastic Beanstalk Using YAML File?

  22. 22

    set read and write permissions to folder and all its parent directories

  23. 23

    Ubuntu Linux server - set file permissions for VirtualBox shared folder

  24. 24

    How do I set permissions on a network-shared folder?

  25. 25

    Is there a way to set permissions of a remote folder via VFS in Java?

  26. 26

    Do application installers set folder permissions? Or is it up to Windows?

  27. 27

    How do I set permissions on directory(folder) on IIS 6.0?

  28. 28

    Can't set permissions on Filenet P8 folder

  29. 29

    Use icacls.exe to set special folder permissions for a domain user

HotTag

Archive