Monday, June 11, 2012

Powershell and Active Directory: Find inactive Computer Accounts in Active Directory using Powershell.



As you know my IT manager always keep me busy. These days we are cleaning our Active Directory. My Today's "Target of the Day" is to find all in-active computer accounts.

first i start thinking how to do it ? to use some filter in "Active Directory Computer and users" or i need to do something else. After few minutes of thinking i thoughts, why not try Powershell. :)

Let's Start.

 Make sure you have "RSAT" installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 


ok, Module is imported,

we are going to use the Active Directory module cmdlet "Get-ADComputer"

"Get-ADComputer" has a property of Enabled which either is "false" or "True", the true means computer account is "enabled" and false means "Computer account is "disabled"

To find all the properties of a single computer account , use the below command.

Get-ADComputer R92DA6V -Properties *

11-06-2012 14-05-15

Ok..not lets find all disabled/in-active computer accounts.

we are going to -filter to to find all inactive account and in Filter we are defining that show all computer who has the value of $false in the property Enabled.

Get-ADComputer -Filter "Enabled -eq '$false'"

11-06-2012 14-05-39

all done ..but lets filter the output to show  us only names.

Get-ADComputer -Filter "Enabled -eq '$false'" | Select Name

11-06-2012 13-56-39

Ahh !! now it's look better...

Now i have the name of all inactive computer accounts in my AD.

Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc



  1. Sorry, but this is not 100% the truth.

    What you see are Computer Objects that are enabled or disabled.
    What you dont see are Computer Objects that are inactive , e.g since 3 months or so...
    only wanted to be precise.

  2. Well articulated !
    Thanks for sharing this.
    By the way, Here is another informative resource which summarizes the steps to find and remove stale users and computer account in active directory without having any interruption -

  3. This comment has been removed by the author.

  4. This comment has been removed by the author.

  5. Thanks, it really very informative article related to how get accurate reports for last logon. I was wondering a tool to know real last logon reports then I found this active directory cleanup tool ( ) that helps to get real last logon report and generate a report of inactive users.