Need a PowerShell script to list shares and share permissions residing on a remote server

Posted on 2008-10-24
Last Modified: 2012-06-27
I'm a VERY new user to powerShell and would like to get a listing of the shares and share permissions on remote servers.  I know the start is "Get-WMIObject Win32_Share -computername myserver" but beyond that I haven't been successful.  What I'm looking for is something like the following:
User1 - modify
User2 - readOnly
Domain Admins - full

Question by:Diannec
  • 2
LVL 18

Expert Comment

ID: 22799791
Do you want NTFS permissions or Share permissions?

Author Comment

ID: 22802735
right now I'm looking for Share permissions
LVL 18

Accepted Solution

BSonPosh earned 250 total points
ID: 22812843
Ah... that is quite another beast.

unfortunately, I believe you need to rely on an external app for this one

rmtshare (from NT 4.0 reskit)

This assumes rmtshare is in your path.
$results = rmtshare.exe $share

$results | ?{$_ -match "\w+\\.+\:"}

Open in new window


Expert Comment

ID: 25578846
I found a webpage describing solution without relying on external tools here:

PS C:\> Get-ShareACL Test
PS C:\> (Get-ShareACL Test).Access

function Get-ShareACL {


    [String]$Name = "%",

    [String]$Computer = $Env:ComputerName



  $Shares = @() 

  Get-WMIObject Win32_Share `

    -Computer $Computer -Filter "Name LIKE '$Name'" | `


      $Access = @();

      If ($_.Type -eq 0) {

        $SD = (Get-WMIObject -Class Win32_LogicalShareSecuritySetting `

          -Computer $Computer `

          -Filter "Name='$($_.Name)'").GetSecurityDescriptor().Descriptor

        $SD.DACL | %{

          $Trustee = $_.Trustee.Name

          If ($_.Trustee.Domain -ne $Null) { $Trustee = "$($_.Trustee.Domain)\$Trustee" }

          $Access += New-Object System.Security.AccessControl.FileSystemAccessRule( `

            $Trustee, $_.AccessMask, $_.AceType)



      $Shares += $_ | 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 }}


  Return $Shares


Open in new window


Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now