Last Rebooted
Hey,
Is there any way or any programs out that will allow you to remotely see when a PC/Server was last rebooted?
Desktop
Hey,
Is there any way or any programs out that will allow you to remotely see when a PC/Server was last rebooted?
by bfilmfan
Assuming this is Microsoft:
Workstation:
net statistics workstation | more
Server:
net statistics server | more
Enjoy.
by bfilmfan
For a remote system, you will need to use a third-party product like CMDInfo by SavillTech, which you can get here:
by blackdiamond
Hey,
Sorry could not get that other program to work.
by blackdiamond
Hey,
Yes it is Windows, Sorry.
That appears to show me the stats for the system I am on. It could be that I am doing it wrong which would not be a first for me.
Maybe I did not phrase it right in the main question.
I am on my system, we'll call it BD1
I want to be able to look at a system called BD2 in a different department and see when it was last rebooted.
Thanx
by 3xp3rt
by blackdiamond
Poster rated this answer.
Have a little vbscript
sServerName = "DC-01" ' obviously, whatever your server's called
Set objWMIService = GetObject ("winmgmts:\\" & sServerName & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dOldLaststart = WMIDateStringToDate(objOS.LastBootUpTime)
Next
wscript.echo "Previous boot up date and time was " & dOldLastStart
wscript.quit
Function WMIDateStringToDate(dBoot)
WMIDateStringToDate = DateAdd("n",cInt(right(dBoot,4)) * -1, _
CDate(Mid(dBoot, 7, 2) & "/" & Mid(dBoot, 5, 2) & "/" & _
Left(dBoot, 4) & " " & Mid (dBoot, 9, 2) & ":" & _
Mid(dBoot, 11, 2) & ":" & Mid(dBoot, 13, 2)))
End Function
You can replace the first line with:
sServerName = inputbox("Please enter server name")
Slightly prettier :)
Ooops, UK date format!
You'll probably want Mid(dBoot,5,2) & "/" & Mid(dBoot,7,2)
Nope. I'll fix it now. You need to change the script according to my second comment as it's set to convert an English DD/MM/YY string to a date and you need MM/DD/YY.
You should change your script so that Line 14 reads:
CDate(Mid(dBoot,5,2) & "/" & Mid(dBoot,7,2) & "/" & _
This swapping of 5 and 7 swaps the DD and MM around so the date string doesn't go out of range.
For instance, my next birthday is 23/02/2006 in English notation and that would cause an error if I tried to convert that string to a US date.
Good luck.
I don't think that you cut-and-pasted my script properly.
In my original, the fourth bit of the composite line in the function (it's really all one long line split by underscores) should read
Mid(dBoot,11,2) & ":" & Mid(dBoot,13,2)))
and not
Mid(dBoot,5,2) & "/" & Mid(dBoot,7,2)))
I just didn't read your version properly so I didn't spot it earlier! D'Oh.
The whole date conversion function should read, for your US dates,
Function WMIDateStringToDate(dBoot)
WMIDateStringToDate = DateAdd("n",cInt(right(dBoot,4)) * -1, _
CDate(Mid(dBoot,5,2) & "/" & Mid(dBoot,7,2) & "/" & _
Left(dBoot,4) & " " & Mid (dBoot,9,2) & ":" & _
Mid(dBoot,11,2) & ":" & Mid(dBoot,13,2)))
End Function
'
sServerName = inputbox("Type the damn name!!")
Set objWMIService = GetObject("winmgmts:\\" & sServerName & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dOldLaststart = WMIDateStringToDate(objOS.LastBootUpTime)
Next
wscript.echo "Previous boot up date and time was " & dOldLastStart
wscript.quit
Function WMIDateStringToDate(dBoot)
WMIDateStringToDate = DateAdd("n",cInt(right(dBoot,4)) * -1, _
CDate(Mid(dBoot,5,2) & "/" & Mid(dBoot,7,2) & "/" & _
Left(dBoot,4) & " " & Mid (dBoot,9,2) & ":" & _
Mid(dBoot,11,2) & ":" & Mid(dBoot,13,2)))
End Function
by blackdiamond
Hey,
Thanx for you help that works great.
by blackdiamond
Hey,
Seems like we may be on the right track. :-))
I am not much of a script writer so I am not sure what I should change. The script is not quite working, I get this error
Line: 14
Char: 1
Error: Type mismatch: 'CDate'
Code: 800A000D
Source:Microsoft VBScript runtime error
Here is my script.
sServerName = inputbox("Insert The Damn Name!!")
Set objWMIService = GetObject ("winmgmts:\\" & sServerName & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dOldLaststart = WMIDateStringToDate(objOS.LastBootUpTime)
Next
wscript.echo "Previous boot up date and time was " & dOldLastStart
wscript.quit
Function WMIDateStringToDate(dBoot)
WMIDateStringToDate = DateAdd("n",cInt(right(dBoot,4)) * -1, _
CDate(Mid(dBoot, 7, 2) & "/" & Mid(dBoot, 5, 2) & "/" & _
Left(dBoot, 4) & " " & Mid (dBoot, 9, 2) & ":" & _
Mid(dBoot,5,2) & "/" & Mid(dBoot,7,2)))
End Function
by blackdiamond
by blackdiamond
Hey,
Made the last change you suggested and nada. It pops up the same error.
I appreciate you efforts in this. Have bumped up the points again.
by blackdiamond
by blackdiamond
This discussion is closed to new replies.
Sort by Trending