13

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
  • 2
    Have you tried anything yet? – Alex McKenzie May 1 '14 at 13:16
  • 1
    Yeah, but I think I finally figured it out, mostly by reading help files :) Get-ADUser -Filter 'teletexterminalidentifier -ge 0' | Export-Csv c:\list.csv Seems to work. How do I do the same thing, but export the value of the teletexterminalidentifier attribute at the same time? – Johan May 1 '14 at 13:20
11

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
  • Unfortunately I get Get-ADUser : Error parsing query: ''teletexterminalidentifier' -like '*'' Error Message: 'syntax error' at position: '1'. – Johan May 1 '14 at 13:37
  • Did you import the module? – Colyn1337 May 1 '14 at 13:39
  • Yes. When I change the command to Get-ADUser -Filter 'teletexterminalidentifier -like "*"' | export-csv c:\list6.csv it works. Just a slight re-working of the syntax. – Johan May 1 '14 at 13:41
4

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
  • That command is prompting me to supply values for "Filter" PS C:\Users\admin\Desktop> Get-ADUser | Where-Object {$_.teletexterminalidentifier -ne $null} | Export-Csv c:\list4.csv cmdlet Get-ADUser at command pipeline position 1 Supply values for the following parameters: (Type !? for Help.) Filter: – Johan May 1 '14 at 13:32
  • 1
    @Johan I added the filter param to the example. – Colyn1337 May 2 '14 at 21:05
1

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.