
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get 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
Advertisements