I am trying to find out login info on a user using this
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server vcenter | where{ $_ -is [VMware.Vim.UserLoginSessionEvent] -and {$_.Username -contains "domain\username"}} | Out-GridView
but I am not seeing the info for the user.
any idea why
Try like this
{
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server $vc |
where { $_ -is [VMware.Vim.UserLoginSessionEvent] -and $_.UserName -eq 'domain\username' } |
Sort-Object -Property CreatedTime -Descending |
select Username, IPAddress, createdtime, USeragent, @{N = 'vCenter'; E = { $vc.Name } }
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The -contains operator checks if the right-hand side value is present in the array on the left side, so that is not the correct operator in this case.
Try with -eq
where { $_ -is [VMware.Vim.UserLoginSessionEvent] -and $_.UserName -eq 'domain\user' } |
Out-GridView
If you want to check for multiple users, you could use the -contains operator.
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server vcsa.local.lab |
where { $_ -is [VMware.Vim.UserLoginSessionEvent] -and 'domain\user1','domain\user2' -contains $_.UserName } |
Out-GridView
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
hi Luc
how can i get the vcenter info as well here?
foreach($vc in $global:DefaultVIServers){
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server $vc | where { $_ -is [VMware.Vim.UserLoginSessionEvent] -and $_.UserName -eq 'domain\username' } |
Sort-Object -Property CreatedTime -Descending | select USername, IPAddress, createdtime, USeragent
}
Try like this
{
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server $vc |
where { $_ -is [VMware.Vim.UserLoginSessionEvent] -and $_.UserName -eq 'domain\username' } |
Sort-Object -Property CreatedTime -Descending |
select Username, IPAddress, createdtime, USeragent, @{N = 'vCenter'; E = { $vc.Name } }
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc
any idea what this is under useragent?
IpAddress CreatedTime UserAgent
x.x.x.x 7/3/2019 8:43:36 AM h5-client/6.5.0
x.x.x.x 7/3/2019 8:43:36 AM h5-client/6.5.0
127.0.0.1 7/3/2019 8:10:13 AM h5-client/6.5.0
That looks like access from the HTML 5 Web Client
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference