We have some groups and/or users that have the wrong Primary SMTP address.
Find all users with primary uppercase
SMTP address of *@example.com
while not including lowercase addresses.
Result should display users Name and Primary Email Address
Tried:
Get-Mailbox -Filter {recipienttypedetails -eq "SharedMailbox"} -ResultSize Unlimited |
where-Object {($_.PrimarySMTPAddress -like "*@example.com")} |
fl displayname,PrimarySMTPAddress
But this returns Users that have "No" uppercase SMTP address. I am looking for users and groups that have the wrong SMTP address but have a correct smtp address. The SMTP addresses need to be corrected.
What you are after is the Get-CASMailbox
cmdlet. The Get-Mailbox
cmdlet would work as well. They both have an overlap on some commands but CASMailbox
is more for configuring ActiveSync and OWA.
Get-CASMailbox -ResultSize unlimited |
where {$_.primarysmtpaddress -like "*@example.com.au"} |
select name, primarysmtpaddress |
Export-CSV C:\temp\file.csv
This should get you to where you need. Filter the data as required
The following seems to be working for me.
Thank you everyone for the help and education.
Sometimes it just takes a little help to find the right track.
Set-ExecutionPolicy RemoteSigned Set-ExecutionPolicy Unrestricted $LiveCred = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection Import-PSSession $Session Connect-MsolService Import-Module Msonline
Get-Mailbox -ResultSize Unlimited | where-Object {($_.PrimarySMTPAddress -like "*@somecompany.com")} | fl displayname,PrimarySMTPAddress
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.