get-acl and split output from accessToString

Posted on 2011-05-11
Last Modified: 2012-05-11
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
$ = $obj
$_.accesstostring |%{
$_ -match "(.+)\s((?:Allow)|(?:Deny))\s(.+)"
$b.security_principal = $matches[1]
$b.type = $matches[2]
$b.rights = $matches[3]
$acls += $b

Open in new window

Question by:daveTechSearch
    LVL 13

    Assisted Solution

    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}}, 

    Open in new window

    LVL 70

    Accepted Solution

    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 :)

    LVL 5

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    This article is intended to be a 2 part Primer to get someone up and running quickly and efficiently in Powershell, but also including small useful tips that you might not find elsewhere.   One of the things I see often is people starting out usi…
    Group Policy Delegation Recently, I was tasked with delegating permissions for a specific group of administrators to a specific list of Group Policy Objects(GPO). A couple of things need to happen here for this to work. If you want the Administrat…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now