Edit

Share via


Disconnect-RdsUserSession

Disconnects a user from their current active session.

Syntax

Default (Default)

Disconnect-RdsUserSession
    [-TenantName] <String>
    [-HostPoolName] <String>
    [-SessionHostName] <String>
    [-SessionId] <Int32>
    [-NoUserPrompt]
    [<CommonParameters>]

Description

The Disconnect-RdsUserSession cmdlet disconnects the user from their current active session running on the specified session host. The user is not logged off, so all applications continue to run. The user can reconnect to their session by launching a connection again in their Remote Desktop client.

Examples

Example 1: Disconnect a user by providing all required information

PS C:\> Disconnect-RdsUserSession -TenantName "contoso" -HostPoolName "contosoHostPool" -SessionHostName "sh1.contoso.com" -SessionId 1

This command disconnects the user on the specified session host associated with the provided session ID. This command requires you to have looked up the user session previously to provide all of the required information. By running the Disconnect-RdsUserSession cmdlet without the NoUserPrompt switch, you will be asked to confirm to disconnect the user.

Example 2: Disconnect a user by searching for their user session

PS C:\> Get-RdsUserSession -TenantName "contoso" -HostPoolName "contosoHostPool" | where { $_.UserPrincipalName -eq "contoso\user1" } | Disconnect-RdsUserSession -NoUserPrompt

This command uses the Get-RdsUserSession cmdlet to search for the specific user's session, then pipes it into the Disconnect-RdsUserSession cmdlet to disconnect the user. By running the Disconnect-RdsUserSession cmdlet with the NoUserPrompt switch, you will not receive any additional prompt to confirm to disconnect the user.

Parameters

-HostPoolName

The name of the host pool.

Parameter properties

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

Parameter sets

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

-NoUserPrompt

The switch indicating that you would like to disconnect the user without any additional confirmation.

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

-SessionHostName

The name of the session host.

Parameter properties

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

Parameter sets

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

-SessionId

The session ID correlating to the user you want to disconnect.

Parameter properties

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

Parameter sets

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

-TenantName

The name of the tenant.

Parameter properties

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

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
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

System.String

System.Int32

Outputs

System.Object