Modify User Permissions using Powershell

Simon Eastwood 26 Reputation points

I am new to PowerShell and I am trying to add a local user called 'Tree' with read-only and list permissions to all files and folders in a directory on my F:\ drive and force the permissions to propagate and not change any existing permissions

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,416 questions
0 comments No comments
{count} vote

Accepted answer
  1. MotoX80 32,326 Reputation points

    You can do it with icacls.exe.

    icacls.exe F:\ /grant "Tree:(OI)(CI)(RX)"

    Or with Powershell cmdlets.

    $Folder = 'F:\'
    $ACL = Get-Acl  $Folder
    $ACL_Rule = new-object System.Security.AccessControl.FileSystemAccessRule ('Tree', "ReadAndExecute",”ContainerInherit,ObjectInherit”,”None”,”Allow”)
    Set-Acl -Path $Folder -AclObject $ACL 

    If you have folders that do not inherit permissions from their parent folder, the access will not be applied to them.

    As always, try this on a test folder first.

0 additional answers

Sort by: Most helpful