none
Find users without customattribute1 set RRS feed

  • Question

  • 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!!

    Monday, August 31, 2015 7:05 PM

Answers

All replies

  • give this a try;

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


    Cheers, Matthew Kerfoot

    Monday, August 31, 2015 7:16 PM
  • 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.


    EDIT: See Leif-Arne's post for the solution for -Filter. I was using -ne, apparently -not -eq does work.

    Monday, August 31, 2015 7:23 PM

  • Get-ADUser -LDAPFilter '(!extensionAttribute1=employee)'
    


    -- Bill Stewart [Bill_Stewart]

    Monday, August 31, 2015 7:27 PM
    Moderator
  • Get-ADUser -Filter '-not ExtensionAttribute1 -eq "employee"' -Properties ExtensionAttribute1

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