< Back

Get-CPermission

Sun Jan 12, 2020 9:48 pm

NAME Get-CPermission



SYNOPSIS

Gets the permissions (access control rules) for a file, directory, registry key, or certificate's private key/key

container.





SYNTAX

Get-CPermission [-Path] <String> [[-Identity] <String>] [-Inherited] [<CommonParameters>]





DESCRIPTION

Permissions for a specific identity can also be returned. Access control entries are for a path's discretionary

access control list.



To return inherited permissions, use the `Inherited` switch. Otherwise, only non-inherited (i.e. explicit)

permissions are returned.



Certificate permissions are only returned if a certificate has a private key/key container. If a certificate

doesn't have a private key, `$null` is returned.





PARAMETERS

-Path <String>

The path whose permissions (i.e. access control rules) to return. File system, registry, or certificate paths

supported. Wildcards supported.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Identity <String>

The identity whose permissiosn (i.e. access control rules) to return.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Inherited [<SwitchParameter>]

Return inherited permissions in addition to explicit permissions.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

System.Security.AccessControl.AccessRule.





-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-CPermission -Path 'C:\\Windows'



Returns `System.Security.AccessControl.FileSystemAccessRule` objects for all the non-inherited rules on

`C:\\windows`.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-CPermission -Path 'hklm:\\Software' -Inherited



Returns `System.Security.AccessControl.RegistryAccessRule` objects for all the inherited and non-inherited rules

on `hklm:\\software`.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-CPermission -Path 'C:\\Windows' -Idenity Administrators



Returns `System.Security.AccessControl.FileSystemAccessRule` objects for all the `Administrators'` rules on

`C:\\windows`.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Get-CPermission -Path 'Cert:\\LocalMachine\\1234567890ABCDEF1234567890ABCDEF12345678'



Returns `System.Security.AccessControl.CryptoKeyAccesRule` objects for certificate's

`Cert:\\LocalMachine\\1234567890ABCDEF1234567890ABCDEF12345678` private key/key container. If it doesn't have a

private key, `$null` is returned.











RELATED LINKS

Carbon_Permission

Disable-CAclInheritance

Enable-CAclInheritance

Get-CPermission

Grant-CPermission

Revoke-CPermission

Test-CPermission