Get-SmbConnection

Retrieve the connections established from the SMB client to any SMB servers.
Users can connect to an SMB share using credentials different than the associated logon credentials so that there will be a connection listed per share per user logon per credential used.

Syntax
      Get-SmbConnection [[-ServerName] String[]] [[-UserName] String[]] [-CimSession CimSession[]]
         [-SmbInstance {Default | CSV}] [-ThrottleLimit Int32] [CommonParameters]

Key
   -CimSession [CimSession[]]
       Run the cmdlet in a remote session or on a remote computer.
       Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet.
       The default is the current session on the local computer.

   -ServerName
       Specifies that the connections made to the server are enumerated.

   -SmbInstance
       Specifies the input to this cmdlet. You can use this parameter, or you can pipe the input to this cmdlet.

   -ThrottleLimit [Int32]
       The maximum number of concurrent operations that can be established to run the cmdlet.
       If this parameter is omitted or a value of 0 is entered, then PowerShell will calculate an optimum throttle limit 
       for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies 
       only to the current cmdlet, not to the session or to the computer.

   -UserName
       Specifies that the connections made by the user are enumerated.

Examples

Get connections from an SMB client to SMB servers:

PS C:\> Get-SmbConnection
    ServerName   ShareName   UserName           Credential       Dialect   NumOpens 
    ----------   ---------   --------           ----------       -------   -------- 
    ServerFS1    work        SS64dom\pc64$      SS64dom\pc64$    3.0.2          1 
    ServerFS1    VMS5        NT VIRTUAL MACHI.. SS64dom\pc89$    3.1.1          3 
    ServerFS     NETLOGON    SS64dom\pc64$      SS64dom\pc64$    3.0.2          1 
    ServerFS     VMS1        SS64dom\user64     SS64dom\user64   3.0.2          5 
    ServerSO     print$      SS64dom\user64     SS64dom\user64   3.0.2          1 

Get connections from an SMB server:

PS C:\> Get-SmbConnection -ServerName Server64 | Select-Object -Property *

“Technology is not neutral. We're inside of what we make, and it's inside of us. We're living in a world of connections — and it matters which ones get made and unmade” ~ Donna Haraway

Related PowerShell Cmdlets:

New-SmbMapping - Create a mapping to an SMB share.
New-PSDrive - Create a mapped network drive (Windows 7).
Get-CimInstance -class Win32_Share - List the available remote shares.
Get-SmbOpenFile - Information about files that are open on behalf of SMB server clients.
Remove-SmbMapping - Remove an SMB Mapping.
Windows cmd command: NET VIEW - list remote shares.


 
Copyright © 1999-2020 SS64.com
Some rights reserved