SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

K. Brian Kelley - Databases, Infrastructure, and Security

Add to Technorati Favorites Add to Google
Author Bio
Brian is a SQL Server author, columnist, and Microsoft MVP focusing primarily on SQL Server security. He is a contributing author for How to Cheat at Securing SQL Server 2005 (Syngress) and Professional SQL Server 2008 Administration (Wrox). Brian currently serves as a database administrator / architect for AgFirst Farm Credit Bank where he can concentrate on his passion: SQL Server. He previously was a systems and security architect for AgFirst Farm Credit Bank where he worked on Active Directory, Windows security, VMware, and Citrix. In the technical community, Brian is president of the Midlands PASS Chapter, an official chapter of PASS. Brian is also a junior high youth minister at Spears Creek Baptist Church in Elgin, SC.
 

WSUS 3.0 - Query to Return Systems That Haven't Checked in Within the Week

Rating: (not yet rated) |  Discuss | 3,919 Reads | 149 Reads in Last 30 Days |no comments

I've been playing with WSUS lately and I've been less than satisfied with the reporting. Since the information I need to get at exists in a SQL Server database, I've been writing my own queries to get it out. Here's a basic query to get out what systems in a particular group haven't checked in within the last week. There are 3 basic tables which have to be put together: tbComputerTarget (contains the information on the computers), tbTargetGroup (contains the information on the groups), and tbTargetInTargetGroup (join table between the two). I have found cases where a system will have checked in to WSUS so that we see it's computer name, IP address, etc., but it doesn't actually report a status time (nor any status information), hence an OR for LastReportedStatusTime is NULL to include those systems, too.

 

DECLARE @GroupName nvarchar(512)
SET @GroupName = '<Group Name>'

SELECT
    FullDomainName
  , IPAddress
  , LastReportedStatusTime
FROM tbComputerTarget CT
 
JOIN tbTargetInTargetGroup TTG
   
ON CT.TargetID = TTG.TargetID
 
JOIN tbTargetGroup TG
   
ON TTG.TargetGroupID = TG.TargetGroupID
WHERE TG.Name = @GroupName
  
AND (DATEDIFF(dd, LastReportedStatusTime, GETDATE()) > 6
           
OR LastReportedStatusTime IS NULL)

 

Comments
There are no comments on this post
Leave a Comment
Only members of SQLServerCentral may leave comments. Register now for your free account or Sign-In if you are already a member.