Created
August 25, 2017 12:55
-
-
Save Sh1n0g1/5677f820c094affaa9f8d84e3fd483f2 to your computer and use it in GitHub Desktop.
Get the active time from Eventlog, login event.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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