Regular/Shared mailboxes

Roger Roger 5,791 Reputation points
2024-08-07T20:58:22.62+00:00

I am using Exchange 2016 hybrid environment. We create users on-premises and migrate them to online(some are created as remote mailbox from onprem). I have email addresses in a CSV file in the format below. I am using an M365 E5 license. I have 40,000 email addresses, and I suspect that 2,000 shared mailboxes are assigned M365 E5 license. I want to identify which addresses in the CSV file are shared mailboxes. Please guide me on how to import the CSV file, determine which addresses are shared mailboxes or regular mailboxes, and export the output to a CSV file. i have procured exchange online plan1 licenses and i want to assign those to the shared mailboxes and remoke M365 license.

email-list

user1@contoso.com

user2@contoso.com

Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,494 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,608 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
2,076 questions
Microsoft Exchange Licensing
Microsoft Exchange Licensing
Microsoft Exchange: Microsoft messaging and collaboration software.Licensing: Rules, regulations, and restrictions that define how software can be used and distributed.
21 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mike Hu-MSFT 3,515 Reputation points Microsoft Vendor
    2024-08-08T07:53:22.2566667+00:00

    Hi,

    Welcome to the Microsoft Q&A forum!

    You can follow these steps using PowerShell. Here’s a step-by-step guide:

    1. Open PowerShell as an administrator.
    2. Connect to Exchange Online:
      
          $UserCredential = Get-Credential
      
          Connect-ExchangeOnline -UserPrincipalName $UserCredential.UserName -Password $UserCredential.Password
      
      
    3. Import the CSV file:
      
          $mailboxes = Import-Csv -Path "C:\path\to\your\file.csv"
      
      
    4. Initialize an array to store the results:
      
          $results = @()
      
      
    5. Loop through each email and check the mailbox type:
      
          foreach ($mailbox in $mailboxes) {
      
              $email = $mailbox.EmailAddress
      
              $mailboxDetails = Get-Mailbox -Identity $email -ErrorAction SilentlyContinue
      
              
      
              if ($mailboxDetails) {
      
                  $isShared = $mailboxDetails.RecipientTypeDetails -eq "SharedMailbox"
      
                  $results += [pscustomobject]@{
      
                      EmailAddress = $email
      
                      MailboxType = if ($isShared) { "SharedMailbox" } else { "RegularMailbox" }
      
                  }
      
              } else {
      
                  $results += [pscustomobject]@{
      
                      EmailAddress = $email
      
                      MailboxType = "NotFound"
      
                  }
      
              }
      
          }
      
      
    6. Export the results to a CSV file:
      
          $results | Export-Csv -Path "C:\path\to\results.csv" -NoTypeInformation
      
      
    7. Identify Shared Mailboxes and update licenses:
      
          $sharedMailboxes = $results | Where-Object { $_.MailboxType -eq "SharedMailbox" }
      
          foreach ($sharedMailbox in $sharedMailboxes) {
      
              $email = $sharedMailbox.EmailAddress
      
              Set-MsolUserLicense -UserPrincipalName $email -RemoveLicenses "ENTERPRISEPACK"
      
              Set-MsolUserLicense -UserPrincipalName $email -AddLicenses "EXCHANGEONLINE_PLAN1"
      
          }
      
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Amit Singh 4,896 Reputation points
    2024-08-09T09:46:07.03+00:00

    To know which email addresses in your CSV file are shared mailboxes and for managing their licenses, you can do this by powershell cmdlet. Follow the steps-

    1.       Firstly, import the CSV file into Powershell

    2.       Check if any email is a shared mailbox

    3.       After that, export the result into the new CSV file

    4.       For shared mailboxes, assign Exchange Online Plan 1 and remove M365 E5 licenses.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.