Get SMBMapping - PowerShell


Overview

The Get-SMBMapping cmdlet retrieves information about Server Message Block (SMB) share mappings on the local computer. It provides insights into network file system (NFS) shares that have been mounted on the system, including their server, share path, local mount point, access rights, and more. This information is valuable for network management, troubleshooting file system issues, and auditing share mappings.

Syntax

Get-SMBMapping [-ComputerName] <string[]> [-Credential] <PSCredential> [-LocalPath] <string>
              [-Path] <string> [-Session] <string>

Options/Flags

  • -ComputerName: Specifies the name of the remote computer where you want to retrieve SMB share mappings. By default, the local computer is targeted.
  • -Credential: Supplies alternative credentials for accessing the remote computer.
  • -LocalPath: Filters the results to include only SMB share mappings with the specified local path.
  • -Path: Retrieves SMB share mappings specific to the provided network path.
  • -Session: Allows you to specify a remote PowerShell session object, enabling the command to operate on the remote computer without establishing a new session.

Examples

Example 1: List all SMB share mappings on the local computer

Get-SMBMapping

Example 2: Retrieve mappings for a specific remote computer

Get-SMBMapping -ComputerName Server01

Example 3: Filter mappings by local path

Get-SMBMapping -LocalPath C:\MySharedFolder

Example 4: Get mappings for a network path on a remote computer

Get-SMBMapping -ComputerName Server02 -Path \\Server02\Share1

Common Issues

  • Invalid computer name: Ensure the specified -ComputerName is correct and accessible.
  • Access denied: Verify that you have sufficient privileges to access the remote computer and retrieve share mapping information.

Integration

Get-SMBMapping can be combined with other PowerShell commands to perform advanced tasks:

  • Use Export-Csv to export mapping information to a CSV file for reporting.
  • Pipe the mapping list to Sort-Object or Where-Object to filter and sort the results.
  • Combine with New-PSDrive to create new PowerShell drives from the SMB share mappings.