Hi to all.

I need a script in Power shell to list all the Shares from a list of servers with a list of users and share permission level.

Something like:

@adrianmagno

4 Spice ups

We are happy to help, but not a script writing service.

What have you tried? Where are you stuck? Feel free to share your code and we’re happy to help you out.

If you post code, please use the ‘Insert Code’ button. Please and thank you!

codebutton_small.png

Thank You Neally for your prompt response. I am trying to use below code which was shared by one of spice works member but are not getting the expected result,

$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: blue;border-collapse: separate;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: lightblue;background-color: #CEE3F6;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: lightblue;}
</style>
"@

function Get-ShareACL {
  param(
    [String]$Name = "%",
    [String]$Computer = $Env:ComputerName
  )
 
  $server = Get-Content C:\temp\test.txt
Foreach-Object {
  
  $Shares = @()
  Get-WMIObject Win32_Share -Computer $server -Filter "Name LIKE '$Name'" |
    ForEach-Object {
      $Access = @()
      if ($_.Type -eq 0) {
        $SD = (Get-WMIObject Win32_LogicalShareSecuritySetting `
          -Computer $server `
          -Filter "Name='$($_.Name)'").GetSecurityDescriptor().Descriptor
        $SD.DACL | ForEach-Object {
          $Trustee = $_.Trustee.Name
          if ($_.Trustee.Domain -ne $null) {
            $Trustee = "$($_.Trustee.Domain)$Trustee"
          }
          $Access += New-Object Security.AccessControl.FileSystemAccessRule(
            $Trustee, $_.AccessMask, $_.AceType)
        }
      }
      $_ | Select-Object Name, Path, Description, Caption,
        @{n='Type';e={
          switch ($_.Type) {
            0          { "Disk Drive" }
            1          { "Print Queue" }
            2          { "Device" }
            2147483648 { "Disk Drive Admin" }
            2147483649 { "Print Queue Admin" }
            2147483650 { "Device Admin" }
            2147483651 { "IPC Admin" }
          }
        }},
        MaximumAllowed, AllowMaximum, Status, InstallDate,
        @{n='Access';e={ $Access }}
  }
}|

ConvertTo-HTML -Fragment

}
$GGG = Get-ShareACL

ConvertTo-HTML -Head $Header -Title "SERVER STATUS" -Body "$GGG" | 
Out-File C:\temp\html.htm

#Scorched-Head was able to achieve the above requirement but that topic has been locked by an administrator and is no longer open for commenting.

Thanks You in Advance.