Invoke-RDUserLogoff

Invoke-RDUserLogoff

Ends a user session and closes all running applications.

Syntax

Parameter Set: Default
Invoke-RDUserLogoff [-HostServer] <String> [-UnifiedSessionID] <Int32> [-Force] [ <CommonParameters>]

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

Parameters

-Force

Indicates that the cmdlet ends the user session and closes all running applications without prompting for user confirmation.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-HostServer<String>

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.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

-UnifiedSessionID<Int32>

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

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

True (ByPropertyName)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • System.Object

Examples

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

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

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

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

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.

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

Disconnect-RDUser

Get-RDUserSession

Send-RDUserMessage