Hello,
I’ve got the cmdlet:
Get-Acl -Path ‘c:\path’ | Format-Table -wrap
which provides a mixed column named ‘Access’
it shows username and it’s access at the same column, how to separate user and the permission in a different columns?
Thanks!
Hello,
I’ve got the cmdlet:
Get-Acl -Path ‘c:\path’ | Format-Table -wrap
which provides a mixed column named ‘Access’
it shows username and it’s access at the same column, how to separate user and the permission in a different columns?
Thanks!
Access is made up of several properties. Format-Table is showing you a friendly view of a few of those properties. If you run this, you can see all of them.
Get-Acl -Path C:\path | select -ExpandProperty Access
Output
$acl.Access
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrators
IsInherited : True
InheritanceFlags : None
PropagationFlags : None
FileSystemRights : FullControl
AccessControlType : Allow
IdentityReference : NT AUTHORITY\SYSTEM
IsInherited : True
InheritanceFlags : None
PropagationFlags : None
FileSystemRights : ReadAndExecute, Synchronize
AccessControlType : Allow
IdentityReference : BUILTIN\Users
IsInherited : True
InheritanceFlags : None
PropagationFlags : None
FileSystemRights : Modify, Synchronize
AccessControlType : Allow
IdentityReference : NT AUTHORITY\Authenticated Users
IsInherited : True
InheritanceFlags : None
PropagationFlags : None
By default, powershell displays objects with 5 or more members as a list like shown. If you want to coerce it to show table, just select the columns you want to see. Four or less will be a table.
Get-Acl C:\Path | Select -ExpandProperty Access | Select IdentityReference,FileSystemRights,AccessControlType
Output
IdentityReference FileSystemRights AccessControlType
----------------- ---------------- -----------------
BUILTIN\Administrators FullControl Allow
NT AUTHORITY\SYSTEM FullControl Allow
BUILTIN\Users ReadAndExecute, Synchronize Allow
NT AUTHORITY\Authenticated Users Modify, Synchronize Allow
You may also consider using calculated properties to show friendlier columns
Get-Acl .\aabc.ics | select -ExpandProperty Access | Select @{N="Target Identity";E={$.IdentityReference}},@{N="Filesystem Rights";E={$.FileSystemRights}},AccessControlType
By the way, Format-Table is fine if you’re just viewing the information in an interactive session and it’s the last command in the pipeline. You can’t use the output from the Format-* cmdlets, such as Sort, Group, or Select. Also, if you try to Format-Table on the Access property, it’s also not pleasing to the eyes.
super. thanks