Find users without customattribute1 set

I can't figure out how to get a list of users who don't have customattribute1 set to employee.  I'm very new to scripting so be gentle.  :)

My latest attempt

 Get-ADUser -filter * -Properties * | ? {$_.customattribute1 -notlike employee}

Any ideas/help?

Thanks!!

August 31st, 2015 3:08pm

give this a try;

Get-ADUser -filter * -Properties * | ? {$_.customattribute1 -eq  "$Null"}

Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 3:19pm

Here's something you can play with:

Get-ADUser -Filter * -Properties ExtensionAttribute1 |
    Where { $_.ExtensionAttribute1 -ne 'employee' }

As a bit of advice, don't use -Properties * unless you really need every single property returned.

I had initially tried to do filtering server side, but didn't get results with my first try so I dropped back to the client side. You may want to look at using -Filter if you're returning a large number of users.

August 31st, 2015 3:26pm

Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 3:30pm

Here's something you can play with:

Get-ADUser -Filter * -Properties ExtensionAttribute1 |
    Where { $_.ExtensionAttribute1 -ne 'employee' }

As a bit of advice, don't use -Properties * unless you really need every single property returned.

I had initially tried to do filtering server side, but didn't get results with my first try so I dropped back to the client side. You may want to look at using -Filter if you're returning a large number of

August 31st, 2015 7:23pm

Get-ADUser -Filter '-not ExtensionAttribute1 -eq "employee"' -Properties ExtensionAttribute1

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 4:29am

Get-ADUser -Filter '-not ExtensionAttribute1 -eq "employee"' -Properties ExtensionAttribute1

  • Proposed as answer by Mike Laughlin Tuesday, September 01, 2015 11:44 AM
September 1st, 2015 8:28am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics