Get SmbShareAccess - PowerShell


Overview

Get-SmbShareAccess retrieves the access control list (ACL) of a specified Server Message Block (SMB) share. This allows you to view the permissions granted to users and groups on the share.

Syntax

Get-SmbShareAccess -Path <string> [[-Force] [-Credential <PSCredential>] [-PassThru]]

Options/Flags

  • -Path: The path to the SMB share for which to retrieve the ACL. The path must be in the form \\<server_name>\<share_name>.
  • -Force: Suppresses the confirmation prompt when removing an ACL entry.
  • -Credential: The credentials to use when connecting to the SMB share. If not specified, the current user’s credentials are used.
  • -PassThru: Returns an object representing the ACL entries rather than just their names.

Examples

Example 1: Get ACL for a specific SMB share

Get-SmbShareAccess -Path \\server01\share01

Example 2: Get ACL using specified credentials

$credential = Get-Credential
Get-SmbShareAccess -Path \\server02\share02 -Credential $credential

Example 3: Remove ACL entries without confirmation

Get-SmbShareAccess -Path \\server03\share03 -Force

Common Issues

  • Ensure that you have the necessary permissions to view the ACL of the SMB share.
  • If connecting to a remote share, verify that the server name and share path are correct.
  • If using a different credential, ensure that it has the appropriate permissions on the share.

Integration

Get-SmbShareAccess can be combined with other PowerShell commands for advanced tasks. For example, you can use it with the Remove-SmbShareAccess command to modify the ACL of a share.

  • Get-SmbShare
  • New-SmbShare
  • Remove-SmbShareAccess