Rename UPN of specific Mailbox Types

Hi All,

Recently i had a customer where the Room Mailboxes had still the Active Directory UPN Suffix.
But that needed to Change in Order to align with Exchange Hybrid / Exchange Online.



So i did write a small PowerShell Script to fix that

The Script can also be found at my GitHub Repo

###############################################################################
# Rename UPN from specific Mailbox Type
# 11.04.2022 V0.1 - Andres Bohren - Initial Version
###############################################################################
$Rooms = Get-Mailbox -RecipientTypeDetails RoomMailbox -Resultsize Unlimited
Foreach ($Room in $Rooms)
{
    $Email = $Room.PrimarySMTPAddress
    $Alias = $Room.Alias
    $UPN = $Room.UserPrincipalName
    Write-Host "Working on: $Email / $UPN" -ForegroundColor Green
    If ($UPN -match "corp.icewolf.ch")
    {
        Write-Host "Match found"
        $NewUPN = $UPN.Replace("corp.icewolf.ch","icewolf.ch")
        Write-Host "NewUPN: $NewUPN"
        Set-Mailbox -Identity $UPN -UserPrincipalName $NewUPN
    }
}




Regards
Andres Bohren