Author Posts

August 17, 2016 at 9:51 am

Hello

I am trying to get a list of AD Contacts that are in a distribution group that do not have a Target Address set.

I am able to get a list of all of the contacts in the group and to bring back the data I want by running the below

$memberof=get-adgroup MyGroup | select -expandproperty distinguishedname
Get-ADObject -Filter 'memberof -eq $memberof -and (ObjectClass -eq "contact")' -properties * |select name,mail,targetaddress

I am then trying to amend this, so it will only bring back results where there is no target address, yet no matter what I do, I get errors in the code.

The idea is then to mail enable the contact where the target address is blank with the value in the mail field (I already have the powershell for this)

Thank you

August 17, 2016 at 11:57 am

It sounds like you need to pipe your statement to Where {$_.targetaddress -eq $null} before your select statement

August 17, 2016 at 12:10 pm

Yes, this has brought the data back I need
Thank you Edmond.