Set Permissions on a File or Directory using PowerShell

Set Permissions on a File or Directory using PowerShell
There are basically two commands which are used to play around with permissions on a fileGet-Acl – The Get-Acl cmdlet gets objects that represent the security descriptor of a file or resource. The security descriptor contains the access control lists (ACLs) of the resource.

The ACL specifies the permissions that users and user groups have to access the resource.

Set-Acl – The Set-Acl cmdlet changes the security descriptor of a specified item, such as a file or a registry key, to match the values in a security descriptor that you supply.

To use Set-Acl, use the Path or InputObject parameter to identify the item whose security descriptor you want to change.

Then, use the AclObject or SecurityDescriptor parameters to supply a security descriptor that has the values you want to apply.

Set-Acl applies the security descriptor that is supplied. It uses the value of the AclObject parameter as a model and changes the values in the item’s security descriptor to match the values in the AclObject parameter.

These Commands are a part of Microsoft.PowerShell.Security PSSnapin

Here im showing an example to change permissions on a folder data placed on my c: drive.

First lets see the current permissions on the folder



<#Now if i again check i see that the folder permissions have been changed
and TempUser Account has been denied to write in a file #>


Please follow and like us:

Share this post

4 thoughts on “Set Permissions on a File or Directory using PowerShell

Post Comment