Remove-RdsSessionHost

Removes a session host from a host pool.

Syntax

Remove-RdsSessionHost
      [-TenantName] <String>
      [-HostPoolName] <String>
      [-Name] <String>
      [-Force]
      [<CommonParameters>]

Description

The Remove-RdsSessionHost cmdlet removes a registered session host from the host pool. To re-register the session host to a host pool, you must re-install the agent with valid registration information for that host pool.

This command will fail if the session host has active user sessions. To complete the removal of the session host, you must first log off all users from the session host using the Invoke-RdsUserSessionLogoff cmdlet or re-run the Remove-RdsSessionHost cmdlet with the Force parameter.

When running this command to remove a session host from a persistent host pool, the user assignment is also removed. This is the only way to re-assign a user to a new session host in a persistent host pool.

Examples

Example 1: Remove a session host that has no active sessions

PS C:\> Remove-RdsSessionhost -TenantName "contoso" -HostPoolName "contosoHostPool" -Name "sh1.contoso.com"

This command removes a session host from a host pool. By running the Remove-RdsSessionHost cmdlet without the Force switch, it will only succeed if there are no active sessions on the specified session host. To force the users to log off of the session host, you can run the Invoke-RdsUserSessionLogoff cmdlet.

Example 2: Remove a session host using the force switch

PS C:\> Remove-RdsSessionhost -TenantName "contoso" -HostPoolName "contosoHostPool" -Name "sh1.contoso.com" -Force

This command removes a session host from a host pool. By running the Remove-RdsSessionHost cmdlet with the Force switch, the session host will be immediately removed from the database, along with the user session information. This does not automatically log off the users and may result in a user losing their session state if they are accidentally disconnected from their session before performing a log off.

Parameters

-Force

Forces the removal of the session host, even if there are user session objects contained with the session host.

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

-HostPoolName

HostPool name.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

SessionHost name.

Type:String
Aliases:SessionHostName
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-TenantName

Tenant name.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Inputs

System.String

Outputs

System.Object