« Retrieve directory size with PowershellCompany name change »

View Virtual Center Sessions


View Virtual Center Sessions

Permalink 11:54:00 am by admin, Categories: Personal

Ever wondered what sessions are connected to your vCenter? Here's a script that will show you in an HTML which users are connected, their Login Time and their Last Active Time.

$a = "<style>"
$a = $a + "BODY{background-color:black;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:darkgrey}"
$a = $a + "TD{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"

Connect-VIServer vcs02.domain.loc

$ServiceInstance = Get-View ServiceInstance
$SessionManager = Get-View $ServiceInstance.Content.SessionManager
$sessions = $SessionManager.SessionList | select UserName,LoginTime,LastActiveTime  | ConvertTo-Html -head $a | Out-File c:\temp\sessions.html
Invoke-Expression c:\temp\sessions.html

Disconnect-VIServer vcs02.domain.loc -Confirm:$false

Source: PeetersOnline (http://www.peetersonline.nl)  and Microsoft (http://technet.microsoft.com/en-us/library/ff730936.aspx)