?
Solved

powershell checking multiple instances

Posted on 2015-02-06
12
Medium Priority
?
19 Views
Last Modified: 2016-06-24
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}
0
Comment
Question by:techdrive
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
12 Comments
 
LVL 40

Expert Comment

by:footech
ID: 40594566
So you want to return the users which have more than one value in proxyAddresses, and ignore all the others?
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40594635
You can use   ...proxyadresses.Count -gt 1   as condition.
0
 

Author Comment

by:techdrive
ID: 40598166
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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 70

Expert Comment

by:Qlemo
ID: 40598310
where {$_.proxyaddresses.count -gt 1}
0
 

Author Comment

by:techdrive
ID: 40598429
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
 
LVL 70

Expert Comment

by:Qlemo
ID: 40598548
Well, then just check for count greater 2!
0
 

Author Comment

by:techdrive
ID: 40598742
well I would like to omit the others and just have smtp.
0
 
LVL 40

Accepted Solution

by:
footech earned 1000 total points
ID: 40598784
You could use something like this.
Get-ADUser -filter * -Properties proxyaddresses | ? {($_.proxyaddresses -like "smtp:*").count -gt 3 }

Open in new window

0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 1000 total points
ID: 40598854
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
 
LVL 40

Expert Comment

by:footech
ID: 40598883
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
 

Author Comment

by:techdrive
ID: 40608426
thanks
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question