Use Get-Acl to Check Permission for a Specific User in PowerShell

MD Aminul Islam Aug 26, 2022
Use Get-Acl to Check Permission for a Specific User in PowerShell

Sometimes we need to check permissions for a specific user. We need this for various purposes, like controlling the access for a particular file. With the help of PowerShell, we can easily see the permissions to access the file.

This article demonstrates how we can check permissions for a specific user. We will also see necessary examples and explanations to make the topic easier.

Below shared a PowerShell script through which we are going to check the permission status for the System Administrators. Therefore, the PowerShell code for our example will look like the one below.

Get-Acl g:\ | Select-Object -ExpandProperty Access | Where-Object identityreference -eq "BUILTIN\Administrators"

Here, we used a particular PowerShell keyword, Get-Acl. This cmdlet creates an object that can represent the security status of a resource or a file.

This is a Security Descriptor containing the file or resource’s Access Control Lists (ACLs) of the file or resource. After running the example code above, you will get an output like the one below.

Output:

FileSystemRights  : 268435456
AccessControlType : Allow
IdentityReference : BUILTIN\Administrators
IsInherited       : False
InheritanceFlags  : ContainerInherit, ObjectInherit
PropagationFlags  : InheritOnly

FileSystemRights  : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrators
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

Important Parameters for Get-Acl in PowerShell

This keyword contains some particular parameters for various purposes. These are discussed below:

-Audit This gets the data of audit for the Security Descriptor from the System Access Control List.
-Exclude This omits the specific item. You have to provide the path here.
-Filter This parameter specifies the filter in the provider’s language or format.
-Include This parameter is only used to get specific items
-InputObject This parameter will provide you with the Security Descriptor for the specific object.
-LiteralPath This parameter is used to specify the path of a resource or file. The value for this parameter should be used as it’s typed.
-Path This parameter holds the path to resources or files.

You can use these valuable parameters as per your requirements. Please note that the example codes shared here are only executable on the Windows PowerShell environment.

MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn

Related Article - PowerShell Script