Find Ad Users with Specific Ad Attribute Not Null

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 :

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

Hope this helps !

Your Answer

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

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest