Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Combining get-user and get-mailbox to get all email addresses for a user

$
0
0

Hi

I need to knock together a list of all mail enabled users and their associate settings from their AD account (company, department, title, city, all that stuff). I need to include *ALL* their SMTP email addresses. 

I'm really struggling to merge my get-mailbox query with my get-users query. Can someone help show me how to pipe get-users in to get-mailbox so that the email fields are populate for each user in turn?

Here are my two scripts, which both give me the separate information I need. 

**********************

Get-User -ResultSize Unlimited | Where { $_.RecipientType -eq 'UserMailbox' } | ft displayname,firstname,lastname,samaccountname,department,city,description,title,company

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}

**********************

Thanks

Olly


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>