Link to home
Start Free TrialLog in
Avatar of ei00004
ei00004Flag for United States of America

asked on

icacls syntax to list only folders that has a specific group and it's permissions to that folder.

I need to know the icacls syntax that will list only the folders that a specific group and the groups permissions to that folder. For example, I already have
[icacls C:\*. /findsid "domain\group" /t /c"] this will list only the folders that "domain\group" has access to. But I also need to be able to list the permission that group has on the folder.

What would be even better, if there is icacls syntax that would only list the folder if the "domain\group" has a specific permissions. For Example, only list the folder C:\temp for "domain\group" if it's permission on the folder is modify 
Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Throw it into PowerShell
icacls c:\scripts /findsid admin-dell\michael /t /c |% { 
    if( $_.StartsWith( 'SID Found: ' ) ) 
    { 
        $file = $_.SubString( 11, $_.Length - 12 ); 
        icacls $file 
    } 
}

Open in new window

You can use a variation on this technique to do your other request (save the result from the second icacls into a temp file and only output it if you find your desired string in the output file).
Avatar of ei00004

ASKER

Thanks, I'll test it.
Avatar of ei00004

ASKER

Ok your script does work, it will list all files and folders with the perms based on the "domain\user". Would it be possible for you to modify this script to only list folders and not files?
sure.
$dirs = dir c:\scripts -Directory
foreach( $dir in $dirs ) 
{ 
    icacls $dir.FullName /findsid admin-dell\michael /c | % {
        if( $_.StartsWith( 'SID Found: ' ) ) 
        { 
            icacls $dir.FullName
        }
    } 
}

Open in new window

Avatar of ei00004

ASKER

This works great! Just one little change, is there a way to make it also scan the sub-folders?
Avatar of ei00004

ASKER

But not the files?
ASKER CERTIFIED SOLUTION
Avatar of Michael B. Smith
Michael B. Smith
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ei00004

ASKER

Perfect! Thank you sir!