Powershell Command : Set-Acl

Set-Acl :

Used to change the Security settings for a resource such as folder, files, registry etc..

Set-Acl Description :

The Set-Acl cmdlet is used for set or change the security descriptor of a resource such as folder, files, registry etc. ACL is called as the Access Control List, it will contain the permissions ie the security descriptor of the resource like the permissions for a user or a group.

Set-Acl Syntax :

Parameter Set: ByPath
Set-Acl [-Path] <String[]> [-AclObject] <Object> [[-CentralAccessPolicy] <String> ] [-ClearCentralAccessPolicy] [-Exclude <String[]> ] [-Filter <String> ] [-Include <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [-UseTransaction] [ <CommonParameters>]

Parameter Set: ByInputObject
Set-Acl [-InputObject] <PSObject> [-AclObject] <Object> [-Exclude <String[]> ] [-Filter <String> ] [-Include <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [-UseTransaction] [ <CommonParameters>]

Parameter Set: ByLiteralPath
Set-Acl [-AclObject] <Object> [[-CentralAccessPolicy] <String> ] -LiteralPath <String[]> [-ClearCentralAccessPolicy] [-Exclude <String[]> ] [-Filter <String> ] [-Include <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [-UseTransaction] [ <CommonParameters>]

Set-Acl Parameters :

-AclObject<Object>

It was used to specify the ACL of the object with the help of the Path or the InputObject parameter.

-Exclude <string[]>

It was used for excluding specific items.

-Filter <string>

It was used for filtering certain objects according to our needs, here we can use the wildcard characters to filter the objects.

-Include <string[]>

It was used for retrieving specific items, here we can use the wildcard characters.

-Passthru

It returns an object that represents the security descriptor or the permission that was changed.

-Path <string[]>

It was used to specify the path to a resource.

-UseTransaction [<SwitchParameter>]

It was used when a transaction is in progress.

-CentralAccessPolicy<String>

It was used for changing the central access policy of an object.

-ClearCentralAccessPolicy

It was used for clearing the central access policy of an object.

-InputObject<PSObject>

It was used for changing the Security descriptor of an object. Cannot use the pipe line here.

-LiteralPath<String[]>

It was used for changing the Security descriptor of an object. Cannot use the wildcard characters here.

-Confirm

Before running a cmdlet it prompts for a confirmation.

-WhatIf

While using this cmdlet, it shows what would happen if the cmdlet runs but it will not execute the command.

CommonParameters:

-Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, -OutVariable.

Get-Acl Examples :

1) Get-Acl command was used to declare a variable and Set-Acl was used to set the security descriptor which was retrived by Get-Acl.

PS C:> $DogACL = Get-Acl C:Dog.txt
PS C:>Set-Acl -Path C:Cat.txt -AclObject $DogACL

2) Pipe line command was used to copy and set the security descriptor to another object.

PS C:> Get-Acl C:Dog.txt | Set-Acl -Path C:Cat.txt

3) Retrieve a security descriptor first and set them to a folder.

PS C:> $NewAcl = Get-Acl File0.txt
PS C:>Get-ChildItem c:temp -Recurse -Include *.txt -Force | Set-Acl -AclObject $NewAcl

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *