Jump to content


khawkins

Query for any machine that last contacted AD over 45 days

Recommended Posts

Hi all,

 

I am struggling to find a query that can do this for me. I am deploying software and I am wanting to add a query that will exclude any machines that haven't contacted AD within the last 45 days.

 

Can anyone assist?

 

Many thanks,

Kevin

Share this post


Link to post
Share on other sites

If they haven't contacted AD, I'd say it's safe to assume that they probably haven't contacted SCCM either. You can use this WQL Query in sccm:

select
	SMS_R_SYSTEM.ResourceID,
	SMS_R_SYSTEM.ResourceType,
	SMS_R_SYSTEM.Name,
	SMS_R_SYSTEM.SMSUniqueIdentifier,
	SMS_R_SYSTEM.ResourceDomainORWorkgroup,
	SMS_R_SYSTEM.Client
from
	SMS_R_System
inner join
	SMS_G_System_CH_ClientSummary
on
	SMS_G_System_CH_ClientSummary.ResourceID = SMS_R_System.ResourceId
inner join
	SMS_G_System_SYSTEM
on
	SMS_G_System_SYSTEM.ResourceId = SMS_R_System.ResourceId
where
	SMS_G_System_CH_ClientSummary.ClientActiveStatus = 0

That'll find all inactive clients. So you can set your threshold for inactive clients to 45 days.

 

I did a bit of research and it looks like this should get clients that haven't logged into AD in 45 days. I haven't done extensive testing with this query, so do some spot checking to be sure it's getting what you need.

select
	SMS_R_System.Name,
	SMS_R_System.LastLogonTimestamp
from
	SMS_R_System
where
	DATEDIFF(dd,SMS_R_System.LastLogonTimestamp,GetDate()) > 45
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.