KelvinTegelaar / CIPP

CIPP is a M365 multitenant management solution
https://cyberdrain.com / https://cipp.app
GNU Affero General Public License v3.0
788 stars 4.78k forks source link

[Feature Request]: Bulk add email alias #2751

Closed Audian-Drew closed 1 month ago

Audian-Drew commented 1 month ago

Description of the new feature - must be an in-depth explanation of the feature you want, reasoning why, and the added benefits for MSPs as a whole.

I believe that adding the ability to bulk add email aliases to a tenant would be a massive time saver for MSPs who don't have a script in place or have permissions set up on technician computers that would prevent lower tier techs from running scripts on their machines.

PowerShell commands you would normally use to achieve above request

Output will be added to C:\temp folder. Open the Add-SMTP-Address.log with a text editor. For example, Notepad.

Start-Transcript -Path C:\temp\Add-SMTP-Address.log -Append

Get all mailboxes

$Mailboxes = Get-Mailbox -ResultSize Unlimited

Loop through each mailbox

foreach ($Mailbox in $Mailboxes) {

# Search for specified SMTP address in every mailbox
$SMTPAddress = $Mailbox.EmailAddresses | Where-Object { $_ -like "*@contoso.com"}

# Do nothing when there is already an SMTP address configured
If (($SMTPAddress | Measure-Object).Count -eq 0) {

    # Change @contoso.com to the domain that you want to add
    $Address = "$($Mailbox.Alias)@contoso.com"

    # Remove the -WhatIf parameter after you tested and are sure to add the secondary email addresses
    Set-Mailbox $Mailbox.DistinguishedName -EmailAddresses @{add = $Address } -WhatIf

    # Write output
    Write-Host "Adding $($Address) to $($Mailbox.Name) Mailbox" -ForegroundColor Green
}

}

Stop-Transcript

KelvinTegelaar commented 1 month ago

Only sponsors can create FRs