powershell checking multiple instances

I have a small issue. I am trying to figure out the best way to be able to tell all accounts with more than one smtp address and x400 addresses. I am using quest and notice the field s proxyaddresses. Any suggestions to be able to pull out all addresses with more than one smtp


proxyaddresses {smtp:user@again.com, smtp:john.doe@again.com}

or                       smtp:oneuseraddress@again.com, x400:c=us;a=;p=microsoft ; o=%; s=oneuseraddress@again.com, x400c=us;a:anotheraddress.com}
techdriveAsked:
Who is Participating?
 
footechConnect With a Mentor Commented:
You could use something like this.
Get-ADUser -filter * -Properties proxyaddresses | ? {($_.proxyaddresses -like "smtp:*").count -gt 3 }

Open in new window

0
 
footechCommented:
So you want to return the users which have more than one value in proxyAddresses, and ignore all the others?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You can use   ...proxyadresses.Count -gt 1   as condition.
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
techdriveAuthor Commented:
Footech yes I would like to only return the users who have more than one proxyaddresses and ignore the others. This is correct.

where {$_.proxyaddress.count -gt 1} <----is this correct Qlemo?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
where {$_.proxyaddresses.count -gt 1}
0
 
techdriveAuthor Commented:
I knew that was too easy. I am trying to get only if the SMTP has more than one. I am finding that all users have x400 and sips. I do not want to pull that info

 smtp:oneuseraddress@again.com, x400:c=us;a=;p=microsoft ; o=%; s=oneuseraddress@again.com, x400c=us;a:anotheraddress.com}
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Well, then just check for count greater 2!
0
 
techdriveAuthor Commented:
well I would like to omit the others and just have smtp.
0
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
Ok, if you cannot rely on always having SMTP and SIP, that makes sense.
I cannot test with Quest ATM, but with Exchange 2007, so you might have to adapt this a little:
? { ($_| Select -Expand ProxyAddresses | ? { $_.PrefixString -eq 'SMTP' }).Count -gt 1 } 

Open in new window

0
 
footechCommented:
Just noticed my number for the count was wrong (change the 3 to a 1 to fit your needs).  Blame it on my testing and pasting.
0
 
techdriveAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.