Invoke-RdsUserSessionLogoff

Logs off a user from their current active session.

Syntax

Invoke-RdsUserSessionLogoff
      [-TenantName] <String>
      [-HostPoolName] <String>
      [-SessionHostName] <String>
      [-SessionId] <Int32>
      [-NoUserPrompt]
      [-Force]
      [<CommonParameters>]

Description

The Invoke-RdsUserSessionLogoff logs off a user their current active session running on the specified session host. Since the user is logged off, all applications will be terminated and there is a potential for data to be lost if the user or applications have not saved opened files.

Examples

Example 1: Log off a user by providing all required information

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

This command logs off 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 Invoke-RdsUserSessionLogoff cmdlet without the NoUserPrompt switch, you will be asked to confirm to log off the user.

Example 2: Log off a user by searching for their user session

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

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

Parameters

-Force

The switch indicating that you would like to log off the user and remove the session from the database, even if the service cannot reach the session host.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-HostPoolName

The name of the host pool.

Type:String
Position:1
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False
-NoUserPrompt

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

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SessionHostName

The name of the session host.

Type:String
Position:2
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False
-SessionId

The session ID correlating to the user you want to log off.

Type:Int32
Position:3
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False
-TenantName

The name of the tenant.

Type:String
Position:0
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False

Inputs

System.String

System.Int32

Outputs

System.Object