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.
 
Step 2: Run the script in the Windows PowerShell Console, type this command: Import-Module <Script Path> at the prompt.
For example, Type Import-Module E:\Script\ListAllSharedFolderPermission.psm1  This is shown in the following figure.
 
Step 3: We can type the command Get-Help  Get-OSCSharedFolderPermission to display the entire help content for this function, such as the syntax, parameters, or examples.
 The script has three parameters:
For example, type the following commands,
$cre = Get-Credential “WIN2008R2-APP1\Administrator”
Get-OSCSharedFolderPermission -ComputerName "WIN2008R2-APP1" as shown below:
This command lists all of share permission of shared folder on the WIN2008R2-APP1 remote computer.
 
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
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