Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

powershell checking multiple instances

Posted on 2015-02-06
12
Medium Priority
?
21 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 41

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 71

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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 71

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 71

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 41

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 71

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 41

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 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