title: Getting Permissions From Remote Share (PowerShell)
body: <p>I am writing a script to get permissions and some other info on shares throughout the a network and I am having trouble getting the shares permissions. I read online that one can use "GetAccessMask" but I thought it was just for the current user.</p>
  
  <pre><code>#loop for each computer in computers file
   ForEach ($computer in $allComputers)
   {
   Write-Host "Checking - $computer"
   If($computer -ne '')
   {
   #check if online, this uses WMI so if you don't have access to the machine it will show as offline
  If(Test-Connection -Computername $computer -ErrorAction SilentlyContinue)
   {
   $shares = Get-WmiObject -Class Win32_share -ComputerName $computer -Credential $uCredentials
   ForEach($share in $shares)
   {
   $sName = $share.Name
   $sPath = $share.Path
   $sDesc = $share.Description
  
   $objShare = New-Object -TypeName PSObject
   $objShare = Add-Member -PassThru -InputObject $objShare -NotePropertyName Server -NotePropertyValue $computer
   $objShare = Add-Member -PassThru -InputObject $objShare -NotePropertyName Online -NotePropertyValue $True
   $objShare = Add-Member -PassThru -InputObject $objShare -NotePropertyName Share -NotePropertyValue $sName
   $objShare = Add-Member -PassThru -InputObject $objShare -NotePropertyName Path -NotePropertyValue $sPath
   $objShare = Add-Member -PassThru -InputObject $objShare -NotePropertyName Description -NotePropertyValue $sDesc
   $objShare | Export-CSV -Path $fOutfile -Append -NoClobber -NoTypeInformation
   }
   }
   }
   }
  </code></pre>
  
  <p>Above is a snippet of my script (as a whole it reads server list from a file, lists the share name,path, description) and I am wondering if anyone knows how I could get permissions on a given share for all users/groups with rights to the share.
  Thanks in advance!</p>