Created
December 13, 2014 22:42
-
-
Save kkamegawa/4b132328de59f79c4d5f to your computer and use it in GitHub Desktop.
Show working time in office. I checked Vista, and Windwos 7.
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
$date = [datetime]::today.adddays(-1) | |
$events = Get-EventLog -LogName system -before $date | where-object {$_.source.startswith("Microsoft-Windows-Kernel") -eq $true -or $_.source.startswith("Microsoft-Windows-Power") -eq $true} | select-object timegenerated,source,InstanceID | |
$poweron = $events | where-object {$_.source -eq "Microsoft-Windows-Kernel-General" -and $_.InstanceID -eq 12} | |
$shutdown = $events | where-object {$_.source -eq "Microsoft-Windows-Kernel-General" -and $_.InstanceID -eq 13} | |
$sleepwakeup = $events | where-object {$_.source -eq "Microsoft-Windows-Power-Troubleshooter" -and $_.InstanceID -eq 1} | |
$sleepgo = $events | where-object {$_.source -eq "Microsoft-Windows-Kernel-Power" -and $_.InstanceID -eq 42} | |
$workend = $shutdown[0].TimeGenerated | |
if($sleepgo -ne $null) { | |
if($shutdown[0].TimeGenerated -lt $sleepgo[0].TimeGenerated) { | |
$workend = $sleepgo[0].TimeGenerated | |
} | |
} | |
$workstart = $poweron[0].TimeGenerated | |
if($sleepwakeup -ne $null) { | |
if($sleepwakeup[0].TimeGenerated -lt $poweron[0].TimeGenerated) { | |
$workstart = $sleepwakeup[0].TimeGenerated | |
} | |
} | |
write-host 前日の勤務はたぶん $workstart から $workend です。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment