Hello,
I need a script to get a csv with logon history in the last 6 months,
Username
Login date
Logout date
Ip source (from where user login)
Thanks
What is the retention period for events in your environment?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
I can see is set on 60 days.
Then you will only be able to collect data for the last 60 days.
Something like this
$events = 'UserLogoutSessionEvent'
$start = (Get-Date).AddMonths(-6)
Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue) -Server mvcs001 |
where{ $_ -is [VMware.Vim.UserLogoutSessionEvent]} |
Sort-Object -Property CreatedTime |
Select UserName,IPAddress,LoginTime,
@{N='LogoutTime';E={[DateTime]($_.FullFormattedMessage -replace '.+login time: (.*), number.+','$1')}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference