Search code examples
windowsazurepowershellazure-powershellvdi

how to sent-RdsUserSessionMessage to users who is using the sessionhost?


I want to send message to the users. I found the Send-RdsUserSessionMessage.

  1. I want to send message to all users who is using the special SessionHostName.
  2. Is it possible to send message to assigned session host of one host pool?

And the samples are as below:

Example 1: Send a message to a user session by providing all required information

PS C:\> Send-RdsUserSessionMessage -TenantName "contoso" -HostPoolName "contosoHostPool" -SessionHostName "sh1.contoso.com" -SessionId 1 -MessageTitle "Test announcement" -MessageBody "Test message."

Example 2: Send a message to a user by searching for their user session

PS C:\> Get-RdsUserSession -TenantName "contoso" -HostPoolName "contosoHostPool" | where { $_.UserPrincipalName -eq "contoso\user1" } | Send-RdsUserSessionMessage -MessageTitle "Test announcement" -MessageBody "Test message." -NoUserPrompt

Solution

  • Regarding #1, based on description section in this document I believe you can lists all user sessions running on the session hosts in the specified host pool using Get-RdsUserSession cmdlet and then pipeline with Send-RdsUserSessionMessage cmdlet to send message to all those user sessions

    Regarding #2, based on example 1 in this document and description section in this document I believe it is possible to assign different session host names of one host pool

    Hope this information helps!