Skip to content

Instantly share code, notes, and snippets.

@Sh1n0g1
Created August 25, 2017 12:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sh1n0g1/5677f820c094affaa9f8d84e3fd483f2 to your computer and use it in GitHub Desktop.
Save Sh1n0g1/5677f820c094affaa9f8d84e3fd483f2 to your computer and use it in GitHub Desktop.
Get the active time from Eventlog, login event.
#Initialize
$Weekday=@("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
$LoginData=@{}
ForEach($w in $Weekday){
$LoginData[$w]=@{}
0..23 | % {$LoginData[$w][$_]=0}
}
#Get the data from Eventlog
$i=0
Get-EventLog -LogName Security | Where EventID -Eq 4624 | Select TimeGenerated | % {
$d=([DateTime]($_.TimeGenerated)).DayOfWeek
$h=([DateTime]($_.TimeGenerated)).Hour
$LoginData[([String]$d)][$h]+=1
$i++;Write-Host "Calculating:"$i
}
#Show weekday vs hour table
&{
Write-Host "[Hour]`t" -n
ForEach($w in $Weekday){
Write-Host $w.SubString(0,3)`t -n
}
Write-Host
ForEach($h in (0..23)){
Write-Host $h -n
ForEach($w in $Weekday){
Write-Host `t $LoginData[$w][$h] -n
}
Write-Host
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment