Share via


How to list Inactive computer Accounts In Cmd or PS

Question

Thursday, October 24, 2013 3:39 AM

I Got a Server 2003 R2 Installed box and conf it as  a domain controller. I raised the domain functional level to 2003 and installed .net and Powershell as well. 

Tried to get Dsquery computer -inactive       on a internet research in tech net but its not working. it just coming to the next prompt when i hit enter.  I thnink there is a problem in my system or something.

Is it possible for me to get inactive computer accounts in my AD?

Please Help.

prabhath

All replies (4)

Thursday, October 24, 2013 4:18 AM ✅Answered

Hi,

Do you have access to any Win7/8 or WS2008R2/12 machines? If so, you can install the ADMG on the 2003 machine and then use the AD PowerShell module available for those OSs to check. The following will return any computer that hasn't been active in the last six months:

Get-ADComputer -Filter * -Properties LastLogonDate | 
    Where { $_.LastLogonDate -lt (Get-Date).AddMonths(-6) }

As for dsquery, you might get better help in the Server General or Directory Services forums.

EDIT: Unless you're specifically looking for a PowerShell way to do this, I suggest going with the oldcmp tool DScripter references below. That'll certainly be the easiest and quickest way to get what you're after.

Don't retire TechNet! - (Maybe there's still a chance for hope, over 12,225+ strong and growing)


Thursday, October 24, 2013 4:20 AM ✅Answered

prabhath,

I often see this tool used by many people, which can help query and/or disable old computer objects: 
http://www.joeware.net/freetools/tools/oldcmp/index.htm

For more information such as a variety of links, and different takes, look at these other threads:
http://social.technet.microsoft.com/Forums/windowsserver/en-US/d9a6325c-7b8a-4f55-9cd8-1c533fa09d6a/dsquery-computer-inactive-can-you-trust-the-result?forum=winserverDS

http://social.technet.microsoft.com/Forums/windowsserver/en-US/88808b2d-472a-457a-829c-66359b875550/how-to-list-and-remove-inactive-or-disabled-computers-from-active-directory-2008r2-tool-or?forum=winserverDS


Thursday, October 24, 2013 5:29 AM ✅Answered

You can use Quests Active Directory tools, ( http://www.quest.com/powershell/activeroles-server.aspx )

And run something like this, (below), this moves the old objects to the OU, OLD. You can also remove them if you want to.

Get-QADComputer -SearchRoot "OU=clients,DC=domain,DC=local" -InactiveFor [insert how many days] | Move-QADObject -NewParentContainer "OU=old,DC=domain,DC=local" -Confirm -Whatif


Thursday, October 24, 2013 7:49 AM ✅Answered

Hi,

dsquery computer forestroot -inactive <NumWeeks>
dsquery computer -inactive 8 -limit 3000.This command returns all stale computer accounts from the Active Directory domain that have not been 'seen' by the domain controllers for a period of 8 weeks.

With Quests Active Directory, we could use below script:

List Inactive Computer Accounts in Active Directory

http://gallery.technet.microsoft.com/scriptcenter/6b8163d1-5fae-43b5-a664-a2d1f6e1e2da

Regards,

Yan Li

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place.