Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, July 25, 2010 5:01 PM
I know we can get this information with uptime.exe /s \mycomputer. But I am looking for a way to do it powershell. Is there any way? I don't want to parse the output of uptime.exe from powershell.
Thanks,
Thanks, Sitaram http://techibee.com http://sitaram-pamarthi.com
All replies (7)
Monday, July 26, 2010 5:53 PM âś…Answered | 4 votes
get-eventlog system | where-object {$_.eventid -eq 6006} | select -first 10
Sunday, July 25, 2010 5:13 PM
I know we can get this information with uptime.exe /s \mycomputer . But I am looking for a way to do it powershell. Is there any way? I don't want to parse the output of uptime.exe from powershell.
Thanks,
Thanks, Sitaram http://techibee.com http://sitaram-pamarthi.com
Actually, this was a part of the 2010 Scripting Games as an event. Well, it was to get the most recent startup of a machine by querying the event logs. So perhaps one of these scripts might help you out.
http://2010sg.poshcode.org/code/search.xhtml?q=Advanced+Event+2
Monday, July 26, 2010 4:54 PM
Thanks for your reply. I couldn't find the one I am looking for. I know that looking at the computer event logs gives me information. I am just wondering how uptime.exe is able do that. I am sure it relies on some other data source and it uses event log as second data source(I saw it displaying such message)Thanks, Sitaram http://techibee.com http://sitaram-pamarthi.com
Monday, July 26, 2010 6:18 PM
http://support.microsoft.com/kb/232243/en-us
It says here that it scans the event logs for times when the computer has been restarted so that would most likely be how it gathers multiple times a system has been restarted.
Otherwise, I am sure it pulls the last uptime of a system from WMI.
(Get-WMIObject Win32_OperatingSystem).LastBootUpTime
Monday, March 14, 2016 10:05 AM | 2 votes
get-eventlog system | where-object {$_.eventid -eq 6006} | select -first 10
Months too late I know, but I prefer to use eventid 6005 as it will also pick up unexpected shutdowns.
Tuesday, April 25, 2017 6:44 AM
Is there a NEW link to this poshcode? Thx
Friday, February 16, 2018 2:55 PM | 2 votes
Even more crispier information through below code,
get-eventlog system | where-object {$_.eventid -eq 6005} | select Timegenerated, EntryType, Source, Message -first 10