SCCM query to get uptime for all machines

hello ,

i need sccm query to get the uptime for machines installed . anyone can help on provide this .

i have the below query and given syntax error :

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
Jaber MMAsked:
Who is Participating?
 
Jason CrawfordTransport NinjaCommented:
I'm not a SCCM guy but PowerShell could provide the info you need:

http://powershellblogger.com/2016/01/get-last-computer-boot-time-or-up-time-with-powershell/
0
All Courses

From novice to tech pro — start learning today.