Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Create Access Control Entries (using PS) with apply to "Subfolders and files only" / "This Folders and Files" and others

$
0
0

Hi All

I have an requirement to set NTFS permissions using Powershell Script. Came with below script to have the permission set:

$pathItem = "C:\TEST"

$objACL = Get-ACL $pathItem
$colRights = [System.Security.AccessControl.FileSystemRights]"FullControl" 
$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::None 
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None 
$objType =[System.Security.AccessControl.AccessControlType]::Allow

$objACERule = New-Object System.Security.AccessControl.FileSystemAccessRule("NT AUTHORITY\Authenticated Users","Modify,Synchronize", $InheritanceFlag, $PropagationFlag, $objType) 

$objACL.AddAccessRule($objACERule) 

Set-ACL $pathItem $objACL

The above script help me to set the permission Apply to : This folder only. But i want to set the permission Apply to: Subfolders and files only.

My current script does the below:

Apply to: This folder only

My requirement is:

Apply To: Subfolders and files only

Please help how can i achieve this.

Thank you


Regards Ram


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>