Exchange Online

Powershell One-liner for finding all objcets that use a spesific domain name in Exchange Online

In some cases we need to find all objects that use a domain name in Exchange Online or Azure AD. For example when we need to remove a domain from a Office 365 tenant. This is not a easy task, unless we are able to script it.

The following three one-liners prints out all email addresses that is active on a object.

Get all users with @mydomain.com

Get-MsolUser -DomainName "mydomain.com"

Get all distribution groups with @mydomain.com

Get-DistributionGroup | foreach {$_.EmailAddresses | ? {$_ -like "*@mydomain.com"}}

Get all dynamic distribution groups with @mydomain.com

Get-DynamicDistributionGroup | foreach {$_.EmailAddresses | ? {$_ -like "*@mydomain.com"}}

Thereafter we can either go in and remove these manually, or we could write a new script that does it for us using the Set-MailUser, Set-Mailbox, Set-DistributionGroup or Set-DynamicDistributionGroup

Making a mailbox shared

When working with SMB customers without a clear IT strategy on how to store communication data between customers, you, at least I, get this question allot.

Hi,

Alex Darrow, who works as a project manager, quit!

He have removed all personal email from his mailbox, and now we want to give Anne Wallace and Sara Davis access to his mailbox.

Can you fix?

Of course I can! What I will do is to convert his mailbox into a shared mailbox, and grant the two users access to it. My first tool will be PowerShell.

Sing in to Exchange Online using PowerShell

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session

Then some magic. With the Set-Mailbox command, I’m converting this mailbox into a shared one

Get-Mailbox -Identity "Alex Darrow " | Set-Mailbox -Type Shared

This task could take some seconds/minutes, so just be patient.

Then I sign in Exchange Admin Center, and check that the account shows under Shared. The great thing about shared mailboxes is that they do not need an Exchange Online license.

Therefore, I sign to Office 365 admin center and remove the license from the user.

When I click save, and then confirm with Yes, I get a warning saying that all data will be removed.

I have still not experienced that a regular mailbox that has been converted to a shared mailbox loses any data when the license is removed, so I click Yes.

Now I rename the account from within Office 365 admin center. This is not required, but it makes management easier later on when accounts have a logical name. I usually append “- Shared” in the Display Name, and just “Shared” in the user name. It’s short and logical.

Then, as a final step, I assign the access rights for the mailbox. I do this via PowerShell, but I could have done just as easy from Exchange Admin Center

Get-Mailbox -Identity "Alex Darrow - Shared" | Add-MailboxPermission -User "Anne Wallace" -AccessRights FullAccess -InheritanceType All

Get-Mailbox -Identity "Alex Darrow - Shared" | Add-MailboxPermission -User "Sara Davis" -AccessRights FullAccess -InheritanceType All

Then ask one of the users to try opening the mailbox. If they use Outlook Web App, they have to manually Open another mailbox

If they are using Office 365 ProPlus, the mailbox is automatically opened next time Outlook starts.

A few notes

The Exchange Online Limits document in the Office 365 Service Description states that a Shared Mailbox only have 10GB of storage, and that it required a license to use futures like Online Archive. However, when you create a new Shared Mailbox, it’s ProhibitSendReceiveQuota is set to 50GB. Therefore, remember to configure this, so you don’t get unexpected NDR reports down the road.
http://technet.microsoft.com/en-us/library/exchange-online-limits.aspx#StorageLimits

Remember to remove the SMTP address from the mailbox, unless you want to risk getting personal mail addressed to Alex.
http://technet.microsoft.com/en-us/library/bb123794(v=exchg.150).aspx

One final thing, which is a tip many should use more often. Always make sure to have a copy of important data before changing stuff in a production environment. Although, in this case Microsoft would be able to restore your data if you should loose anything, by making a Service Request, it gives a extra good feeling knowing that: If I screw up this, I will be able to fix it 🙂

Repost: Common mailbox / folder sharing scenarios

These guides are just so great that I just have to repost them.

First posted at http://community.office365.com/en-us/blogs/office_365_community_blog/archive/2014/01/10/common-mailbox-folder-sharing-scenarios-guided-walkthroughs-now-available.aspx and http://blogs.technet.com/b/exchange/archive/2014/01/09/common-mailbox-folder-sharing-scenarios-guided-walkthroughs-now-available.aspx

They all address some of the most frequent asked questions I get when it comes to features in Office 365 and Exchange Online. Happy reading 🙂