Set-Acl
Use Set-Acl to apply a security descriptor to a file, folder or registry key.
Documentation: Microsoft Learn — Set-Acl
Syntax
See the command anatomy
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
Set-Acl [-Path] <String[]> [-AclObject] <Object> [-ClearCentralAccessPolicy] [-Passthru] [-Filter <String>] [-WhatIf] [-Confirm] [<CommonParameters>]- Stage 1Set-Acl
-Path -AclObject -ClearCentralAccessPolicy -Passthru -Filter -WhatIf -Confirm
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Follow the objects
Run the command to inspect each stage.
Examples
Set-Acl -Path C:\Scripts
Show reference output
Sample output · fictional data, shaped like the real thing
Directory: C:\ Path Owner Access ---- ----- ------ Scripts BUILTIN\Administrators NT AUTHORITY\SYSTEM Allow FullControl...
Set-Acl -Path C:\Scripts (2)
Show reference output
Sample output · fictional data, shaped like the real thing
(No pipeline output. Inheritance was disabled on the in-memory ACL object; existing rules were preserved.)
Set-Acl -Path C:\Scripts (3)
Show reference output
Sample output · fictional data, shaped like the real thing
Path : C:\Scripts
Owner : BUILTIN\Administrators
Access : NT AUTHORITY\SYSTEM Allow FullControl
BUILTIN\Administrators Allow FullControl
BUILTIN\Users Allow ReadAndExecute, SynchronizeParameters
Parameter definitions:
-Path-AclObject-ClearCentralAccessPolicy-Passthru-Filter-WhatIf-Confirm
Practical use and troubleshooting
Practical scenario: Use Set-Acl when you need to apply a security descriptor to a file, folder or registry key. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.
Common error and fix: Access denied when applying an ACL requires the appropriate rights on the target. Save the current descriptor, inspect the proposed rules and avoid copying unrelated inheritance settings blindly. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.
See also: Get-Acl. Get-Acl retrieves a security descriptor; Set-Acl applies one. Review the intended access rules and ownership before writing a descriptor back to a file or directory. Read the linked command before substituting it; similar names do not imply identical inputs or output.
Recap
Set-Acl Use Set-Acl to apply a security descriptor to a file, folder or registry key.
Next: Get-Acl