Set-RdsSessionHost
Sets the state of a session host.
Syntax
Set-RdsSessionHost
[-TenantName] <String>
[-HostPoolName] <String>
[-Name] <String>
[-AllowNewSession]
[-AssignedUser]
[<CommonParameters>]
Description
The Set-RdsSessionHost cmdlet sets the state of the specified session host. You can either disable or enable new connections to the session host. Changing this property on the session host does not affect any user sessions on the session host.
Examples
Example 1: Disable new connections to a session host (aka, set the host to drain mode)
PS C:\> Set-RdsSessionHost -TenantName "contoso" -HostPoolName "contosoHostPool" -Name "sh1.contoso.com" -AllowNewSession $false
SessionHostName : sh1.contoso.com
TenantName : contoso
TenantGroupName : Default Tenant Group
HostPoolName : contosoHostPool
AllowNewSession : False
Sessions : 1
LastHeartBeat : 1/1/2018 12:00:00 PM
AgentVersion : 1.0.0.1
AssignedUser :
Status : Available
StatusTimestamp : 1/1/2018 12:00:00 PM
This command disables the session host from receiving any new connections and removes it as a candidate for load balancing. Any existing sessions on the server will remain there until the user is logged off. An administrator can force a logoff with the Invoke-RdsUserSessionLogoff cmdlet.
Example 2: Enable new connections to a session host (aka, remove the host from drain mode)
PS C:\> Set-RdsSessionHost -TenantName "contoso" -HostPoolName "contosoHostPool" -Name "sh1.contoso.com" -AllowNewSession $true
SessionHostName : sh1.contoso.com
TenantName : contoso
TenantGroupName : Default Tenant Group
HostPoolName : contosoHostPool
AllowNewSession : True
Sessions : 1
LastHeartBeat : 1/1/2018 12:00:00 PM
AgentVersion : 1.0.0.1
AssignedUser :
Status : Available
StatusTimestamp : 1/1/2018 12:00:00 PM
This command enables the session host to receive new connections and is now a candidate for load balancing.
Example 3: Assign a user to a personal desktop session host
PS C:\> Set-RdsSessionHost -TenantName "contoso" -HostPoolName "contosoPersonalDesktops" -Name "sh1.contoso.com" -AssignedUser user1@contoso.com
SessionHostName : sh1.contoso.com
TenantName : contoso
TenantGroupName : Default Tenant Group
HostPoolName : contosoPersonalDesktops
AllowNewSession : True
Sessions : 1
LastHeartBeat : 1/1/2018 12:00:00 PM
AgentVersion : 1.0.0.1
AssignedUser : user1@contoso.com
Status : Available
StatusTimestamp : 1/1/2018 12:00:00 PM
This command assigns the session host in a personal desktop host pool to user1@contoso.com. This user will now connect to this session host when connecting to the pool.
Parameters
-AllowNewSession
A switch with two potential values:
- True, specifying that the session host can be assigned new user sessions by the broker.
- False, specifying that the session host will not be assigned any new user sessions (aka drain mode).
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-AssignedUser
User to be assigned to the personal desktop session host.
Type: | String |
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 |
Accept wildcard characters: | False |
-Name
The fully-qualified domain name (FQDN) of the session host.
Type: | String |
Aliases: | SessionHostName |
Position: | 2 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TenantName
The name of the tenant.
Type: | String |
Position: | 0 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
System.String
Outputs
Microsoft.RDInfra.RDManagementData.RdMgmtSessionHost