WIndows PowerShell Scripting

I am trying to get all the security groups attached to specific Shared folders on my Windows 2008 File Server. I have all of the share paths that I want in an excel spreadsheet.I would like to be able to just plug in all the path locations for the folders/shares and incorporate this powershell cmd to get a full listing of all 900 shares.


Get-Acl -Path D:\Data | Format-List accessToString | Out-File -FilePath c:\GroupShareAccess.txt -Append


Does anyone know how I can script this cmd instead of having to use it on each individual path location ?
sodapop7Asked:
Who is Participating?
 
daveTechSearchConnect With a Mentor Commented:
To continue with what you have. First, I'd change the xls file to a csv so it can be easily read in by Powershell
 
get-content c:\get-acl.csv | foreach { get-acl -path $_ | format-list accessToString} |
    Out-File -FilePath c:\GroupShareAccess.txt -Append
0
 
KenMcFConnect With a Mentor Commented:
You can try this. Just save the column to a text file.

$shares = get-content c:\shares.txt
Foreach ($share in $shares){
Get-Acl -Path $share | Format-List accessToString | Out-File -FilePath c:\GroupShareAccess.txt -Append
}
0
 
sodapop7Author Commented:
Thank a lot. This solved my issue. Both solutions worked for me. I just have one more question. Is there a way to include the path along with the security information that this script spits out ?
0
 
daveTechSearchCommented:
you can do something like this for including the path

$shares = get-content c:\get-acl.csv 
$shareACLs = "c:\shareACLs.csv"

@(foreach ($share in $shares)
    {
    $share | 
    select  @{Name='ShareDir';Expression={[string]($share)}},@{Name='accessToString';Expression={get-acl $share | select accessToString}}
    }) |
    export-csv $shareACLs -notype

Open in new window

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.