VMware Cloud Community
tdubb123
Expert
Expert
Jump to solution

need to find out login info in vcenter

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

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, @{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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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

Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server vcsa.local.lab |

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

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

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

}

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

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, @{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

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

Thanks Luc

Reply
0 Kudos
tdubb123
Expert
Expert
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That looks like access from the HTML 5 Web Client


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

Reply
0 Kudos