Get-SmbSession

Retrieves information about the SMB sessions that are currently established between the SMB server and the associated clients.

Syntax

Default (Default)

Get-SmbSession
    [[-SessionId] <UInt64[]>]
    [[-ClientComputerName] <String[]>]
    [[-ClientUserName] <String[]>]
    [[-ScopeName] <String[]>]
    [[-ClusterNodeName] <String[]>]
    [-IncludeHidden]
    [-SmbInstance <SmbInstance>]
    [-CimSession <CimSession[]>]
    [-ThrottleLimit <Int32>]
    [-AsJob]
    [<CommonParameters>]

Description

The Get-SmbSession cmdlet retrieves basic information about the Server Message Block (SMB) sessions that are currently established between the SMB server and the associated clients.

Examples

Example 1: Get session information

PS C:\>Get-SmbSession
SessionId                     ClientComputerName            ClientUserName                NumOpens
---------                     ------------------            --------------                --------
85899345929                   [fe80::c8c0:f65d:3bc6:7313]   Contoso\Contoso-FS1$          0
4415226380377                 192.168.102.14                Contoso\Contoso-HV2$          1
4415226380385                 192.168.102.14                Contoso\Contoso-HV2$          1
4415226380393                 192.168.102.14                Contoso\Contoso-HV2$          5
8813272891397                 [fe80::6484:f325:adff:39eb]   Contoso\Contoso-FS2$          0
8813272891441                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891449                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891457                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891461                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891469                 192.168.101.13                Contoso\Contoso-HV1$          5
8813272891489                 192.168.102.14                Contoso\Contoso-HV2$          1
8813272891493                 192.168.102.14                Contoso\Contoso-HV2$          1
8813272891517                 192.168.102.14                Contoso\Contoso-HV2$          5
8813272891581                 192.168.102.13                Contoso\Contoso-HV1$          1
8813272891585                 192.168.102.13                Contoso\Contoso-HV1$          1
8813272891609                 192.168.102.13                Contoso\Contoso-HV1$          3
8813272891613                 192.168.101.13                Contoso\Contoso-HV1$          2
8813272891621                 192.168.101.13                Contoso\Administrator         0

This command retrieves information about the SMB sessions that are currently established between the SMB server and the associated clients.

Example 2: Get information for a specific session

PS C:\>Get-SmbSession -SessionId 8813272891621
SessionId                     ClientComputerName            ClientUserName                NumOpens
---------                     ------------------            --------------                --------
8813272891621                 192.168.101.13                Contoso\Administrator         0

This command retrieves information about the SMB session identified as 8813272891621 that is currently established between the SMB server and the associated clients.

Example 3: Get session information for a specific client

PS C:\>Get-SmbSession -ClientComputerName "192.168.102.14"
SessionId                     ClientComputerName            ClientUserName                NumOpens
---------                     ------------------            --------------                --------
4415226380377                 192.168.102.14                Contoso\Contoso-HV2$          1
4415226380385                 192.168.102.14                Contoso\Contoso-HV2$          1
4415226380393                 192.168.102.14                Contoso\Contoso-HV2$          5
8813272891489                 192.168.102.14                Contoso\Contoso-HV2$          1
8813272891493                 192.168.102.14                Contoso\Contoso-HV2$          1
8813272891517                 192.168.102.14                Contoso\Contoso-HV2$          5

This command retrieves information about the SMB sessions that are currently established between the SMB server and the SMB client at the IP address 192.168.102.14.

Example 4: Get session information for a client

PS C:\>Get-SmbSession -ClientUserName "Contoso\Contoso-HV1$"
SessionId                     ClientComputerName            ClientUserName                NumOpens
---------                     ------------------            --------------                --------
8813272891441                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891449                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891457                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891461                 192.168.101.13                Contoso\Contoso-HV1$          1
8813272891469                 192.168.101.13                Contoso\Contoso-HV1$          5
8813272891581                 192.168.102.13                Contoso\Contoso-HV1$          1
8813272891585                 192.168.102.13                Contoso\Contoso-HV1$          1
8813272891609                 192.168.102.13                Contoso\Contoso-HV1$          3
8813272891613                 192.168.101.13                Contoso\Contoso-HV1$          2

This command retrieves information about the SMB sessions that are currently established between the SMB server and the SMB client that has the user name Contoso\Contoso-HV1$.

Example 5: Get all information for a session

PS C:\>Get-SmbSession -SessionId 8813272891441 | Select-Object -Property *
ClientComputerName    : 192.168.101.13
ClientUserName        : Contoso\Contoso-HV1$
ClusterNodeName       : Contoso-FS1
Dialect               : 3.00
NumOpens              : 1
ScopeName             : Contoso-FS
SecondsExists         : 45346
SecondsIdle           : 33
SessionId             : 8813272891441
TransportName         :
PSComputerName        :
CimClass              : ROOT/Microsoft/Windows/SMB:MSFT_SmbSession
CimInstanceProperties : {ClientComputerName, ClientUserName, ClusterNodeName, Dialect...}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

This command retrieves all of the information about the SMB session identified as 8813272891441 that are currently established between the SMB server and the SMB client.

Parameters

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-CimSession

Runs 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.

Parameter properties

Type:

CimSession[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:Session

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ClientComputerName

Specifies the client computer name from which the only sessions are returned.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ClientUserName

Specifies the name of the user whose sessions are retrieved.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:3
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ClusterNodeName

Specifies, in the case of a share hosted by a Windows cluster, the name of the server which is hosting the sessions is retrieved.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:5
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-IncludeHidden

Indicates that sessions that are created and used internally are enumerated also.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ScopeName

Specifies the scope of the sessions being retrieved.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:4
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-SessionId

Specifies the identifiers (IDs) that uniquely identify the sessions for which the information is retrieved.

Parameter properties

Type:

UInt64[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-SmbInstance

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

Parameter properties

Type:SmbInstance
Default value:None
Accepted values:Default, CSV, SBL, SR
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ThrottleLimit

Specifies 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 Windows PowerShell® calculates 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.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

CimInstance

The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#) provides the namespace and class name for the underlying WMI object. The MSFT_SmbSession object represents the sessions established between the SMB server and the associated clients.