Invoke-RDUser Logoff

Ends a user session and closes all running applications.

Syntax

Invoke-RDUserLogoff
      [-HostServer] <String>
      [-UnifiedSessionID] <Int32>
      [-Force]
      [<CommonParameters>]

Description

The Invoke-RDUserLogoff cmdlet ends a user session and closes any running applications.

To end a session without closing applications use the Disconnect-RDUser cmdlet.

To get the ID for the user session that you are ending, use the Get-RDUserSession cmdlet. Because the user session ID is unique only within the context of a session host, a different session within a deploymenthost server can share the same user session ID. The host server and session ID that you specify in this cmdlet uniquely identify a session within a deployment.

Examples

Example 1: End a session connected to an RD Session Host server

PS C:\> Invoke-RDUserLogoff -HostServer "rdsh-1.contoso.com" -UnifiedSessionID 2

This command ends the user session that has the ID 2, which is connected to the host server named rdsh-1.contoso.com.

Example 2: End a session connected to an RD Virtualization Host server

PS C:\> Invoke-RDUserLogoff -HostServer "rdvh-1.contoso.com" -UnifiedSessionID 14 -Force

This command ends the user session that has the ID 14, which is connected to the virtualization host server named rdvh-1.contoso.com. Because the command includes the Force parameter, it ends the session without prompting for user confirmation.

Required Parameters

-HostServer

Specifies the name of the server that hosts the session. For session collections the server name is the name of the Remote Desktop Session Host (RD Session Host) server. For virtual desktop collections the server name is the name of the Remote Desktop Virtualization Host (RD Virtualization Host) server.

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

Specifies a unique session ID on the host. Use Get-RDUserSession to retrieve the unique ID for a specific user session.

Type: Int32
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

Optional Parameters

-Force

Forces the command to run without asking for user confirmation.

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

Outputs

System.Object