Syntax error How to get the Shared folder permissions with PowerShell?

How to get the Shared folder permissions with PowerShell?



To get the shared folder permissions using PowerShell, we can use the Get-SmbShare cmdlet.

For example, we have a shared folder name DSC and we need to retrieve its permissions, we can use the below command.

Command

Get-SmbShare -Name DSC

Output

Name ScopeName Path Description
---- --------- ---- -----------
DSC       *   E:\DSC

It doesn’t show the permission by default and we can retrieve the full list using Fl *. For example,

Get-SmbShare -Name DSC | fl *

And you can see the PresentPathACL property there. This property is used to retrieve the permissions on the shared folder. So we can directly use the command,

Command

(Get-SmbShare -Name DSC).PresetPathAcl

Output

Directory: E:\
Path Owner                   Access
---- -----                   ------
DSC BUILTIN\Administrators   Everyone Allow ReadAndExecute, Synchronize

To get the shared folder permission from the remote computer use,

Invoke-Command -ComputerName Labmachine2k16 -ScriptBlock {
   Get-SmbShare -Name DSC} | Select -ExpandProperty PresetPathAcl

Another direct command, you can use is Get-SmbShareAccess

Command

Get-SmbShareAccess -Name "Shared folder"

Output

PS C:\Temp> Get-SmbShareAccess -Name "Shared folder"
Name          ScopeName AccountName AccessControlType AccessRight
----          --------- ----------- ----------------- -----------
Shared folder    *       Everyone          Allow          Read
Updated on: 2021-03-01T10:47:51+05:30

22K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements