Yeah, I got it from here: http://www.scomgod.com/?p=652

SCCM Query: Uptime and Last Reboot Time | SCOM 
GOD<http://www.scomgod.com/?p=652>
www.scomgod.com
This site is a collection of tools and tips that I needed to place in the 
cloud. I have given credit where credit is due and respect all the hard work of 
those in the ...



I'm curious if the number of servers on this report should be the same number 
as servers found on other server related reports I run (e.g. patch reports)? It 
always seems like there is a discrepancy.


Brian

________________________________
From: [email protected] <[email protected]> on behalf 
of Marcum, John <[email protected]>
Sent: Friday, October 7, 2016 11:20:34 AM
To: [email protected]
Subject: [mssms] RE: Uptime and Last Reboot for Servers

All the quotes are messed up. Remove them and type them back in. Did you get 
this off the internet somewhere?




From: [email protected] [mailto:[email protected]] On 
Behalf Of Brian McDonald
Sent: Friday, October 7, 2016 11:11 AM
To: [email protected]
Subject: [mssms] Re: Uptime and Last Reboot for Servers

[External Email]

I'm aware I was missing the 'S' in Select in the below. Here is the FULL query 
i'm running. [?]


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

________________________________
From: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>> on 
behalf of Brian McDonald 
<[email protected]<mailto:[email protected]>>
Sent: Friday, October 7, 2016 10:55:41 AM
To: [email protected]<mailto:[email protected]>
Subject: [mssms] Uptime and Last Reboot for Servers


Hello everyone,



I'm trying to determine the uptime and last reboot for servers. Below is the 
query I am trying to execute:


ELECT
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



I'm getting a syntax error,
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '''.



Can someone tell me what I'm doing wrong?



Thank you,



Brian




________________________________

Confidentiality Notice: This e-mail is from a law firm and may be protected by 
the attorney-client or work product privileges. If you have received this 
message in error, please notify the sender by replying to this e-mail and then 
delete it from your computer.




Reply via email to