View Server Last Reboot query

From ConfigMgr, how can I get a list of servers with the last reboot time?

Use this query as a starting point, modify as needed, create a report if this information is needed on a frequent basis.


SELECT
cs.Name0 AS 'ComputerName',
DATEDIFF(HOUR, os.LastBootUpTime0, ws.LastHWScan)
AS 'Uptime (in Hours)',
CONVERT(VARCHAR(26), os.LastBootUpTime0, 100)
AS 'Last Reboot Date/Time',
CONVERT(VARCHAR(26), ws.LastHWScan, 101)
AS 'Last Hardware Inventory'
FROM
dbo.v_GS_WORKSTATION_STATUS ws
LEFT OUTER JOIN dbo.v_GS_Operating_System os
ON ws.ResourceID = os.ResourceID
LEFT OUTER JOIN dbo.v_GS_COMPUTER_SYSTEM cs
ON cs.ResourceID = os.ResourceID
WHERE os.Caption0 LIKE '%server%'
ORDER BY os.LastBootUpTime0 ASC

Filed under: SQL, SQL Server

email

Written by , Posted .
  • GeorgeB

    This query is handy after we patch servers.
    Another query that would be helpful is one that lists servers pending a restart. I have not been able to get an accurate report on this since we upgraded to 2012 SP1. What are you thoughts?