Automation

 View Only
  • 1.  Disconnect user sessions

    Posted May 07, 2021 05:40 PM

    I am new to this topic and I want to know how to remotely disconnect a users session from powercli

     


  • 2.  RE: Disconnect user sessions

    Posted May 07, 2021 05:45 PM

    Use the Disconnect-VIServer cmdlet



  • 3.  RE: Disconnect user sessions

    Posted May 07, 2021 05:57 PM

    Thank you for answering so quickly. I don't have good English, but could you give me an example? I need is to close or disconnect the session of a specific user. How would you do it? I am used Horizon.



  • 4.  RE: Disconnect user sessions

    Posted May 07, 2021 06:23 PM

    In that case you could do something like this

    $userName = 'domain\user'
    
    $sessMgr = Get-View SessionManager
    $sessions = $sessMgr.SessionList | 
        where{$_.UserName -eq $userName -and $_.UserAgent -match 'PowerCLI' -and $_.Key -ne $sessMgr.CurrentSession.Key} |
        Select-Object -ExpandProperty Key
    
    $sessMgr.TerminateSession($sessions)
    


  • 5.  RE: Disconnect user sessions

    Posted May 10, 2021 04:26 PM

    Thanks for your answer, but it is for Vcenter, not Horizon.
    What would it be like for Horizon?



  • 6.  RE: Disconnect user sessions

    Posted May 10, 2021 04:50 PM

    It would have been handy if you mentioned that from the start.

    In any case, have a look at Need script to log off all sessions for particular... - VMware Technology Network VMTN



  • 7.  RE: Disconnect user sessions

    Posted May 10, 2021 05:33 PM

    Hello again. Please, I need to know how to disconnect a user's session by powercli with Horizon 7.6.
    Grateful.