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
}
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
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