by namerg at 2012-10-17 15:11:36
Hello all,by DonJ at 2012-10-17 15:24:28
Goal: Query AD users from a certain OU that have empty values in the telephone number
The following instruction will get me all telephone numbers as well the empty ones.
Get-ADUser -SearchBase "OU=upi,DC=example DC=com" -Filter * -Properties telephoneNumber | Select telephoneNumber
And, if i run the the following instruction
Get-ADUser -SearchBase "OU=upi,DC=example,DC=com" -Filter *
I will get all the listing of AD users as below:
DistinguishedName : CN=Admin, SQL,OU=UPI,DC=example,DC=com
Enabled : True
GivenName : SQLadmin
Name : Admin, SQL
ObjectClass : user
ObjectGUID : 6786619e-4277-4743-a121-7e059d0b6bec
SamAccountName : sqladmin
SID : S-1-5-21-1875664707-4292556452-2117001115-1617
Surname :
UserPrincipalName : sqladmin@example.com
What if I want the same list as above but for users who have the Telephone Number empy, with no value ?
Thanks for your help,
G
Moving to our AD forum.by namerg at 2012-10-18 07:48:01
Well, the solution is this one:
Get-ADUser -SearchBase "OU=upi,DC=example,DC=com" -Filter * -Properties telephonenumber | ? {(-not($_.telephonenumber))}