Maybe this is working for you?
foreach ($Computer in Get-Content c:\temp\ComputerNames.txt)
{
Get-WmiObject Win32_Share -computerName $Computer | Select PSComputerName,Name, Caption, Path | where {$_.Name -NotLike “*$”} | Export-csv -append "c:\temp\ServerShares.csv" -NoTypeInformation
}
foreach ($Computer in Get-Content c:\temp\ServerShares.csv)
{
$values = $Computer -split(",") -replace('"',"")
$ComputerName = $values[0]
$shareName = $values[1]
$unc = "\\$ComputerName\$shareName"
Get-ACL -Path $unc | Select -expand access | where {$_.Name -NotLike “*$”} # | Export-csv -append "c:\temp\ServerSharesACL.csv" -NoTypeInformation
}
I am pretty sure it's possible to get this easier/shorter done. But this works for me ;-)
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten