The script:
import-module RemoteDesktop Get-RDUserSession -ConnectionBroker connectionbroker.domain.local | select username, hostserver, unifiedsessionid | Out-GridView -title "Select users to message" -passthru | Send-RDUserMessage -MessageTitle "Message from Tech Support" -MessageBody "Server will be rebooting shortly please save your work."
The result:
After selecting “ok” this appears on the RDSH server.
Why does it work?
Well send-rdusermessage really only requires the hostserver, and unifiedsessionid, these are passed by the pipeline which lets us message the proper users!