VMware Cloud Community
tekhie
Contributor
Contributor
Jump to solution

VC login Information

Hi, I am trying to create a script to show me all the VC logins in the previous 24 hours. I have managed to get as far as the script below ... but i need to be able to filter only on login accounts containig "_uk" - can anyone help - i have tried many things but it still shows me all INFO messages and for all login accounts

$report = @()

get-vievent -Types Info -Start (Get-Date).adddays(-1) | %{

$row = "" | Select Time, Text, User

$row.Time = $_.createdTime

$row.Text = $_.fullFormattedMessage

$row.User = $_.userName

$report += $row

}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try this

$report = @()
 get-vievent -Types Info -Start (Get-Date).adddays(-1) | `
   where {$_.GetType().Name -eq "UserLoginSessionEvent" -and ([regex]"_uk$").Match($_.userName).success }  | %{
   $row = "" | Select Time, Text, User
   $row.Time = $_.createdTime
   $row.Text = $_.fullFormattedMessage
   $row.User = $_.userName
 $report += $row
}


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

Try this

$report = @()
 get-vievent -Types Info -Start (Get-Date).adddays(-1) | `
   where {$_.GetType().Name -eq "UserLoginSessionEvent" -and ([regex]"_uk$").Match($_.userName).success }  | %{
   $row = "" | Select Time, Text, User
   $row.Time = $_.createdTime
   $row.Text = $_.fullFormattedMessage
   $row.User = $_.userName
 $report += $row
}


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

0 Kudos