Monday, June 11, 2012

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

 

HI,

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.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

Rabbit_Wants_beer

4 comments:

  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.

    ReplyDelete
  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 - http://community.spiceworks.com/how_to/125704-how-to-find-and-remove-stale-ad-users-and-computer-in-active-directory

    ReplyDelete
  3. Very well and informative Content given about New Delhi Real Estate Property.
    3bhk Flats in Sector 128

    ReplyDelete