- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PowerCLI script to send message to all desktops in a specific pool
I am working on a PowerCLI script that will filter all sessions within a specific Horizon pool, send a warning message to those filtered sessions via the Session_SendMessage API call, then wait a certain amount of time before logging them off. The filtering and logging off portion does not seem to be the issue, but rather the Session_SendMessage portion. Here is what I have so far:
Connect-HVServer <server>
$Services1 = $Global:DefaultHVServers.ExtensionData
$Sessions = (Get-HVLocalSession).NamesData
ForEach ($Session in $Sessions) {
IF ($Session.DesktopName -eq "TEST") {
Write-Host `n "Connection to TEST found" $Session.Username }
$Services1.Session.Session_SendMessage($session.id, "INFO", "Your session will be logged out in 10 minutes for maintenance. Please save your work!")
}
In order to confirm that $Sessions variable was working correctly I threw in the the Write-Host portion. In the TEST pool I have specified, I do get a return (there is only one session logged into that pool at the moment). The problem is what follows after the API call:
Not entirely sure what I'm doing wrong...