Hi, we have a hybrid Exchange setup and we’re trying to find all mailboxes that don’t have 2 smtp email addresses / proxy addresses. I can check it on either the Exchange server or a DC, whichever would be easier, but below is what I’ve been trying.
This works fine in listing the mailboxes that have it assigned, but I need to find the ones that don’t. It’s a Monday and I can’t think of how to do the reverse, would I have to use a “If…Then” statement or something?
Also, there should be two smtp addresses, domain.onmicrosoft.com and domain.mail.onmicrosoft.com, so I need to search and make sure both are there.
Are the “wrong” people in possession of a blank address? And I’m thinking that the field is actually a collection capable of holding multiple values - which means -notlike wouldn’t work. You’d need a -notcontains or something, but those don’t do wildcards. You might end up just enumerating every user and running through a ForEach to examine each one. I’m not sure AD is going to be able to filter this server-side for you.
Yeah the EmailAddresses property from Get-Mailbox can contain multiple addresses (X500, smtp, etc.) and each user should have a few already because of an email address policy. I tried it with -notcontains as well, still no luck
This is a bit too complicated for a one liner. Emailaddresses is a collection of objects. It would probably be easier to write a function to test them.