Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.42 KB

File metadata and controls

44 lines (33 loc) · 1.42 KB

M365

📖 What is shared mailbox

Shared mailboxes don’t require a separate license.
Multiple users can send/receive mail from one address.
Calendar included — useful for team scheduling.
Permissions-based access (Read, Send As, Send on Behalf).

How to Add to your M365 environment shared mailboxes via PowerShell script

param (
    [Parameter(Mandatory=$true)]
    [string]$MailboxName,

    [Parameter(Mandatory=$true)]
    [string]$EmailAddress,

    [Parameter(Mandatory=$true)]
    [string[]]$Users
)

# Connect to Exchange Online
Write-Host "Connecting to Exchange Online..." -ForegroundColor Cyan
Connect-ExchangeOnline -UserPrincipalName (Read-Host "Enter your admin UPN")

# Create the shared mailbox
Write-Host "Creating shared mailbox: $MailboxName <$EmailAddress>" -ForegroundColor Green
New-Mailbox -Name $MailboxName -Shared -PrimarySmtpAddress $EmailAddress

# Assign permissions to users
foreach ($user in $Users) {
    Write-Host "Granting Full Access and Send As permissions to $user..." -ForegroundColor Yellow

    Add-MailboxPermission -Identity $MailboxName -User $user -AccessRights FullAccess -InheritanceType All
    Add-RecipientPermission -Identity $EmailAddress -Trustee $user -AccessRights SendAs -Confirm:$false
}

# Confirm creation
Write-Host "`nShared mailbox created and permissions assigned successfully." -ForegroundColor Green

# Disconnect
Disconnect-ExchangeOnline