Automation

 View Only
  • 1.  Filtering session IDs for a specific Horizon Pool

    Posted Mar 02, 2021 08:41 PM

    Currently, I am working on automating an automatic sign off of a specific Horizon Pool via PowerCLI. The sign off functionality works no problem, but I am wanting to send a message to all machines in this pool notifying users that the machines will be logged off in X amount of minutes. The most feasible way to do this via the API seems to be using the session_sendmessages method. 

    So far, I know I can grab session ids using Get-HVLocalSession. This works fine, but it lists all current session ids, and I only need the ids from a specific desktop pool. If I can figure out how to narrow down the results, I should be able to use the following command via the API documentation:

    $Services1.session.Session_SendMessages($session.id, "INFO", "Test message")

    Does anyone know of a way to narrow down the results of Get-HVLocalSession to specific desktop pool ids?



  • 2.  RE: Filtering session IDs for a specific Horizon Pool

    Posted Mar 07, 2021 09:14 PM

    Ciao

    Try this script, I've done some tests and it seems to work (Try it first in test environment before add the send message command and logoff command  )

    Connect-HVServer <Horizon Server>
    $PoolName="<PoolName to export SessionId>"
    $sessions=@()
    $sessions=(get-hvlocalsession).namesdata
    $sessionsID=@()
    $PoolsessionID=@()
    $sessionsID=(get-hvlocalsession).id
    for ($i=0; $i -lt $sessions.length; $i++) {
            if ( $sessions[$i].DesktopName -eq $PoolName )
                   {
                  $PoolsessionID+=$sessionsID[$i]
                  }
    }

     

    In the array $PoolsessionID you will have the list of session ids.

    I hope to be proved helpful.

    Fabio 

    blog: BIOLNX – vmvirtual.blog



  • 3.  RE: Filtering session IDs for a specific Horizon Pool

    Posted Apr 20, 2021 07:47 PM

    Sorry for the delay in my response. I just now noticed it.

    This worked perfectly!

    Thank you so much!