VMware Cloud Community
N4N0S
Contributor
Contributor

Disconnect user sessions

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

 
Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership

Use the Disconnect-VIServer cmdlet


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

Reply
0 Kudos
N4N0S
Contributor
Contributor

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.

Reply
0 Kudos
LucD
Leadership
Leadership

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)


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

Reply
0 Kudos
N4N0S
Contributor
Contributor

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

Reply
0 Kudos
LucD
Leadership
Leadership

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


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

Reply
0 Kudos
N4N0S
Contributor
Contributor

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

Reply
0 Kudos