public/Get-TimeSinceReboot.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<# .Synopsis Get the time since the last reboot. .Description Get the time since the last reboot of the system. .Example PS C:\> Get-TimeSinceReboot Returns the time since the last system reboot. #> function Get-TimeSinceReboot { [CmdletBinding()] [OutputType([TimeSpan])] param ( ) begin { Write-LogMessage -Message "Started execution" } process { return New-TimeSpan -Start (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime -End (Get-Date) } end { Write-LogMessage -Message "Finished execution" } } |