get-acl and split output from accessToString

I am attempting to return the accessToString on multiple files in order to output the data and determine current access... this is getting me what I want with one exception... only "one entry" is returned per file, where I know there are multiple... need to figure out how to split the output for accesstostring
foreach($obj in $queryList){
$a = get-acl $obj | select fullname,pschildname,accesstostring
$acls = @()
$a |% {
$b = ""|select name,security_principal,type,rights
$b.name = $obj
$_.accesstostring |%{
$_ -match "(.+)\s((?:Allow)|(?:Deny))\s(.+)"
$b.security_principal = $matches[1]
$b.type = $matches[2]
$b.rights = $matches[3]
$acls += $b
}
}
$acls
}

Open in new window

LVL 5
daveTechSearchAsked:
Who is Participating?
 
Chris DentPowerShell DeveloperCommented:
I would do...
foreach($obj in $queryList){  
  Get-Acl $obj | Select-Object -ExpandProperty Access | Select-Object @{n="name";e={ $obj.fullname }}, 
    @{n="security_principal";e={ $_.identityreference }},
    @{n="type";e={ $_.accesscontroltype }},
    @{n="rights";e={ $_.filesystemrights }}
}

Open in new window

The other has too many loops for me :)

Chris
0
 
soostibiCommented:
There is no sense in working with the AccessToString, if you want to use the portions of that. It's much simpler to use the raw objest instead:
foreach($obj in $queryList){  
    get-acl $obj | %{$_.access} | ForEach-Object {
        $_ | Select-Object @{n="name";e={$obj.fullname}}, 
            @{n="security_principal";e={$_.identityreference}},
            @{n="type";e={$_.accesscontroltype}},
            @{n="rights";e={$_.filesystemrights}}
    }
}

Open in new window

0
 
daveTechSearchAuthor Commented:
Perfect!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.