SCUG.dk
System Center User Group Denmark
Report all workstations that haven’t rebooted the last 7 days

This report will list all workstations (XP, Vista and Windows 7) that hasn’t restarted the last 7 days.

The report

image

The SQL statement

Create a new empty report and copy this SQL code into the SQL statement box:

SELECT     TOP (100) PERCENT dbo.v_R_System.Name0, dbo.v_GS_OPERATING_SYSTEM.LastBootUpTime0, DATEDIFF(Day, 
                      dbo.v_GS_OPERATING_SYSTEM.LastBootUpTime0, GETDATE()) AS [Days since last boot], dbo.v_GS_OPERATING_SYSTEM.Caption0 
FROM         dbo.v_GS_OPERATING_SYSTEM INNER JOIN 
                      dbo.v_R_System ON dbo.v_GS_OPERATING_SYSTEM.ResourceID = dbo.v_R_System.ResourceID 
WHERE     (DATEDIFF(Day, dbo.v_GS_OPERATING_SYSTEM.LastBootUpTime0, GETDATE()) > 7) AND (dbo.v_GS_OPERATING_SYSTEM.Caption0 LIKE '%xp%') OR 
                      (dbo.v_GS_OPERATING_SYSTEM.Caption0 LIKE '%Windows 7%') OR 
                      (dbo.v_GS_OPERATING_SYSTEM.Caption0 LIKE '%vista%') 
ORDER BY [Days since last boot]

The Query

To use this in a query based collection or normal query paste this WQL into the query statement:

select distinct SMS_R_System.Name, SMS_G_System_OPERATING_SYSTEM.LastBootUpTime, SMS_G_System_OPERATING_SYSTEM.Caption from  SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceID = SMS_R_System.ResourceId where (SMS_G_System_OPERATING_SYSTEM.Caption like "%xp%" or SMS_G_System_OPERATING_SYSTEM.Caption like "%vista%" or SMS_G_System_OPERATING_SYSTEM.Caption like "%windows 7%") and (DateDiff(day, SMS_G_System_OPERATING_SYSTEM.LastBootUpTime, GetDate()) >7)

Posted 10-02-2009 12:51 by Kent Agerlund
Filed under: ,
Copyright SCUG.dk
Powered by Community Server (Commercial Edition), by Telligent Systems