VMware Cloud Community
fborges555
Enthusiast
Enthusiast
Jump to solution

send a message to VDI pool

HI

Looking for a script where I can send a message to a specific VDI pool, any help appreciated 

Thanks a bunch

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

0 Kudos
7 Replies
LucD
Leadership
Leadership
Jump to solution

0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

HI L.

 

I did try the following after your suggestion:

$hvserver = connect-hvserver -server 10.10.10.10
$hvservices=$HVServer.ExtensionData
 $sessions=get-hvlocalsession
 $Poolname="IO"
 foreach ($session in $sessions){

 if($session.DesktopName -eq "$Poolname"){

 $sessionId = $session.Id
 Write-Host "Connection to $Poolname found: " $session.username
 $hvservice.session.Session_SendMessage($sessionid,"INFO","TEST")

}

}

 

     I ran this and even though I got no error whatsoever, The message does not show on the VDI 

 

Thanks a bunch

0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

L

after fixing a few things that works on my env. I ended with the following:

foreach ($session in $sessions){

if($session.NamesData.DesktopName -eq "$Poolname"){

$sessionId = $session.Id
Write-Host "Connection to $Poolname found: " $session.username
$hvservices.session.Session_SendMessage($sessionid,"INFO","We are performing a disk expansion on the IO VDI pool, we would like this to happen as soon as the CHG is approved")

}

}

 

But I get the following error:

Exception calling "Session_SendMessages" with "3" argument(s): "ExceptionType : VMware.Hv.SecurityError
ErrorMessage : Session is not authenticated"
At line:8 char:7
+ $hvservices.session.Session_SendMessages($sessionid,"INFO","We ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException

 

what am I missing

Thanks a bunchhh

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did the connect-hvserver -server 10.10.10.10 return an object indicating success?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
fborges555
Enthusiast
Enthusiast
Jump to solution

I think it did , as when I don't I usually get an error

also I don't know if this is a good indicator but when I ran $sessions , I get a list of all :

VMware.Hv.SessionId VMware.Hv.SessionNamesData VMware.Hv.SessionLocalReferenceData VMware.Hv.SessionData, taking there is a connection established to the connection server correct?

hope this help

Thanks a bunch

0 Kudos
LucD
Leadership
Leadership
Jump to solution

0 Kudos
RetouwNL
Enthusiast
Enthusiast
Jump to solution

use rest api's Sending messages to Horizon Sessions using Powershell & REST api’s – Retouw.nl



Previously known as Magneet or Magneet_NL, does things with Horizon api's, see www.retouw.nl
0 Kudos