Author Posts

March 23, 2017 at 3:11 pm

I am trying to produce output from relational data where two properties are of string and collection.

Get-ChildItem 'X:\Some Path' |Get-Acl |Format-Table @{...}

produces:

Path                FileSystemRights     AccessControlType  IdentityReference  IsInherited  InheritanceFlags  PropagationFlags
----                ----------------     -----------------  -----------------  -----------  ----------------  ----------------
X:\Some Path\fileA  Modify, Synchronize  Allow              dom\User000        True         None              None
                    Modify, Synchronize  Allow              dom\User001        True         None              None
                    Modify, Synchronize  Allow              dom\User002        True         None              None
                    Modify, Synchronize  Allow              dom\User003        True         None              None
X:\Some Path\fileB  Modify, Synchronize  Allow              dom\User000        True         None              None
                    Modify, Synchronize  Allow              dom\User001        True         None              None
                    Modify, Synchronize  Allow              dom\User002        True         None              None
                    Modify, Synchronize  Allow              dom\User003        True         None              None

So the content of Path is

Convert-Path $_.PSPPath

and the content of the remaining fields is the result of each FileSystemAccessRule in the $_.Access collection.

Is that possible?

March 23, 2017 at 11:29 pm

Not with just

Format-Table

unfortunately, but you can do it like this:

Get-ChildItem | Get-Acl | ForEach-Object {
    $acl = $PSItem
    $acl.Access | Add-Member -NotePropertyName Path -NotePropertyValue (Convert-Path $acl.PSPath) -PassThru
} | Format-Table Path, FileSystemRights, AccessControlType, IdentityReference, 
                 IsInherited, InheritanceFlags, PropagationFlags