Functions/Get-WorkingTime.ps1
function Get-WorkingTime { # version 1 $Date = Get-Date $Today = [string]$Date.Day + [string]$Date.Month + [string]$Date.Year #$ComputerinfoTempFile = $ComputerinfoTempFile = "$($env:TEMP)\ComputerInfo_$($Today).csv" if(!(Test-Path $ComputerinfoTempFile)) { Get-ComputerInfo | Export-Csv -Path $ComputerinfoTempFile -NoTypeInformation } $WT = [ordered]@{} $Computerinfo = Import-Csv $ComputerinfoTempFile $OsLastBootUpTime = Get-Date -Date $Computerinfo.OsLastBootUpTime $WT["StartTijd"] = Get-Date $OsLastBootUpTime -Format "HH:mm:ss" $WorkingTime = (Get-Date) - $OsLastBootUpTime $WT["TijdGewerkt"] = $WorkingTime $HoeLangNog = (Get-Date -Hour 8 -Minute 30 -Second 0) - $WorkingTime $WT["HoeLangNog"] = Get-Date $HoeLangNog -Format "HH:mm:ss" $HoeLangNogHalveDag = (Get-Date -Hour 4 -Minute 0 -Second 0) - $WorkingTime $WT["HoeLangNogHalveDag"] = Get-Date $HoeLangNogHalveDag -Format "HH:mm:ss" $WT["JeMoetTot"] = Get-Date $OsLastBootUpTime.AddMinutes(510) -Format "HH:mm:ss" return $WT } |