Formatter help

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Patrick Meinecke Patrick Meinecke 1 month, 1 week ago.

  • Author
    Posts
  • #67075
    Profile photo of Ritmo2k
    Ritmo2k
    Participant

    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?

  • #67132
    Profile photo of Patrick Meinecke
    Patrick Meinecke
    Participant

    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
    

You must be logged in to reply to this topic.