Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pipe find specifid string into systeminfo output so only that line is exported
- systeminfo | find "System Boot Time" > SystemBootTime.txt
- #Insert file contents into new variable
- $BootTimeString = Get-Content .\SystemBootTime.txt
- #Edit contents of the previous variable to make it ead like a date and make a new variable from it
- $BootTimeValue = $BootTimeString.TrimStart("System Boot Time: ") -replace '[,]'
- #force the fomatting of the previous variables content into a datetime type and place in a new variable
- $BootTime = [datetime]::ParseExact("$BootTimeValue", 'dd/MM/yyyy HH:mm:ss', $null)
- #Get the current time
- $Now = Get-Date
- #Compare the boot time with the current time and format the output into total minutes and current seconds.
- NEW-TIMESPAN -Start $BootTime -End $Now | Select-Object @{Label="Minutes";Expression={[math]::Floor($_.TotalMinutes)}}, Seconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement