PS – Get All SMB shares with permissions

  acl, powershell, server, windows

I’m trying to get all smb shares on my windows server with all user permissions on them for inventory check.

This is what i have:

$Shares = Get-SmbShare

foreach($Share in $Shares)
{
    Get-SmbShareAccess -Name $Share.Name | Where-Object {$_.AccountName -Match "DOMAINNAME"} 
}

Which gets me all domain users with their shares and which access they have.

But it only shows name of folder. I would like its gonna show full path on the server (Not UNC)

And it would be exportable in csv format.

When i do:

$Shares = Get-SmbShare

foreach($Share in $Shares)
{
    Get-SmbShareAccess -Name $Share.Name | Where-Object {$_.AccountName -Match "PRAGUELOFTS"} | Export-Csv -Path C:perms.csv
}

It only exports the last user.

Source: Windows Questions

LEAVE A COMMENT