M HYPE SPLASH
// updates

Find AD users with specific AD attribute NOT null

By John Peck

I'm looking for a script/Powershell command that will list all AD users that have a value not NULL in the teletexterminalidentifier attribute, so they must have a value set.

By default this attribute is not set but we have an app that modifies this attribute (to contain a hexadecimal string), so I'm looking for a list of all users that have this attribute set to something.

Thanks!

2

3 Answers

You should be able to get the users by using:

Get-ADUser -Filter 'teletexterminalidentifier -like "*"'

You can then filter what you need by piping the command:

Get-ADUser -Filter 'teletexterminalidentifier -like "*"' | Select-Object name,teletexterminalidentifier | Export-Csv file.csv

Where Select-Object lets you select what fields you want to get the info from by name.

3

I think what you're looking for is the Where-Object cmdlet. Here's some pseudo code to help you:

Get-ADUser -Filter * | Where-Object {$_.teletexterminalidentifier -ne $null} | Export-Csv c:\list.csv
2

If you want to filter users based on this property, you have to add the -properties switch to the Get-ADuser Cmdlet. Indeed, without this switch, it loads only basic properties (members) for user objects.

Thus, here is the full command to achieve what you want :

Get-ADUser -filter * -Properties * | ? {$_.teletexterminalidentifier -ne $null} | Select-Object CN,SamAccountName,Teletexterminalidentifier

It will produce this kind of result :enter image description here

Then you will be able to export the result into the desired format.

Hope this helps !

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy