Lists all the shared folder permissions or NTFS permissions (PowerShell)

Introduction

This PowerShell script illustrates how to list all the shared folder permissions and NTFS permissions.

Scenarios

In many cases, users want to check many share folders permission one by one. If we can use the script to list these share folders permission, it will really useful.

Script

Step 1: Click Start, type powershell in the search box on the Start Menu, right-click the Windows PowerShell icon, and then click Run Windows PowerShell as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.

Step2: Start the PowerShell Console with administrator. To run the script in the Windows PowerShell Console, type the command< Script Path> at the Windows PowerShell Console.

For example, you can type the command Get-Help C:\Script\ListAllSharedFolderPermission.ps1 -Full to display the entire help file for this function, such as the syntax, parameters, or examples. This is shown in the following figure.

 The script has three parameters:

For example, type the following commands,

$cre = Get-Credential “WIN-FJ6FH2787QS\Administrator”

C:\Script\ListAllSharedFolderPermission.ps1 -ComputerName "WIN-FJ6FH2787QS" as shown below:

This example lists all of share permission of shared folder on the WIN-FJ6FH2787QS remote computer.

Here are some code snippets for your references.

PowerShell
Edit|Remove
if($Credential) 
{     
    $SharedNTFSSecs = Get-WmiObject-Class Win32_LogicalFileSecuritySetting ` 
    -Filter"Path='$SharedFolderPath'"-ComputerName $ComputerName-Credential $Credential 
} 
else 
{ 
    $SharedNTFSSecs = Get-WmiObject-Class Win32_LogicalFileSecuritySetting ` 
    -Filter"Path='$SharedFolderPath'"-ComputerName $ComputerName 
}

Prerequisite

Windows PowerShell 2.0

Additional Resources

Win32_LogicalShareSecuritySetting

Related forum threads:

http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/f4fd65d3-17f4-4561-a501-6286f9c1e8dd 
http://groups.google.com/group/powershell-users/browse_thread/thread/43f06ce172e68c38 
http://social.technet.microsoft.com/Forums/en/winserverpowershell/thread/1903cfde-ad34-464e-9419-94d07ed9de88