Thursday, November 20, 2014

Give modify permissions to the folder and subfolder using Power shell Script

   

1:  $Right = [System.Security.AccessControl.FileSystemRights]"Modify"
   2:  $InheritanceFlag = ([System.Security.AccessControl.InheritanceFlags]::ContainerInherit, [System.Security.AccessControl.InheritanceFlags]::ObjectInherit)
   3:  $PropagationFlag = [System.Security.AccessControl.PropagationFlags]::InheritOnly  
   4:  $objType =[System.Security.AccessControl.AccessControlType]::Allow
   5:  $objUser = New-Object System.Security.Principal.NTAccount("domain\username") 
   6:   
   7:  $objACE = New-Object System.Security.AccessControl.FileSystemAccessRule($objUser, $Right, $InheritanceFlag, $PropagationFlag, $objType) 
   8:   
   9:  $objACL =  Get-Acl “C:\test”
  10:  $objACL.AddAccessRule($objACE)
  11:  Set-ACL  “C:\test” -aclobject $objACL

No comments:

Post a Comment