Set-RdsSessionHost
Sets the state of a session host.
Syntax
Default (Default)
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).
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-AssignedUser
User to be assigned to the personal desktop session host.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-HostPoolName
The name of the host pool.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | 1 |
| Mandatory: | True |
| Value from pipeline: | True |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-Name
The fully-qualified domain name (FQDN) of the session host.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | SessionHostName |
Parameter sets
(All)
| Position: | 2 |
| Mandatory: | True |
| Value from pipeline: | True |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
-TenantName
The name of the tenant.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | 0 |
| Mandatory: | True |
| Value from pipeline: | True |
| Value from pipeline by property name: | True |
| Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.