Wednesday, June 13, 2012

Powershell and Active Directory: Find all Active Directory users whose CITY property field in blank.

 

Hi,

Me again , yes yes i know , now you are going to ask me ,,"Aman" what is your task for the day",, ok ok telling you..Today my manager told me to find all  active directory users which don't have the CITY field set or those users whose CITY field is blank in there user properties.

I know that Active Directory Module has a Cmdlet to find users which is : Get-ADUser

 

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,

To find all users in AD we need to user -Filter * and to get there all properties we need to use -Properties * parameters.

Get-ADUser -Filter * -Properties *

13-06-2012 12-02-27

but our target it to find CITY field which is blank., let's use Where-Object cmdlet to do this.

In this command we are asking powershell to Find all users with all of there properties and then then show is only those users whose CITY property is $null or blank.

Get-ADUser -Filter * -Properties * | Where-Object { $_.City -eq $null}

this is showing us huge amount of data.

13-06-2012 12-07-13

Lets just select names of the users only.

Get-ADUser -Filter * -Properties * | Where-Object { $_.City -eq $null} | Select Name

13-06-2012 12-09-21 

Wow !! i have the names of all users whose City filed in blank.. i can export it to CSV files and sent to my Manager :)

Thanks for reading

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

penguin

4 comments:

  1. I think, this is really very well information given about Powershell and Active Directory: Find all Active Directory users whose CITY property field in blank. Thanks for given this information here about this blog.
    Flats in Sithalapakkam

    ReplyDelete
  2. Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.

    Packers and Movers Sithalapakkam Chennai

    ReplyDelete
  3. Well and informative content given about Latest Property in Delhi, DLF Capital Greens. Thanks for given this information here about this blog.
    Office Spaces for Rent in Sector 58

    ReplyDelete
  4. I think, this is really very well and informative content given about Delhi property: Circle rates raised by up to 250. Thanks for given this informative content provided about Delhi property: Circle rates raised by up to 250. Thanks for provide this information here about this blog.
    2bhk Flats in Sector Omega-1

    ReplyDelete