Help - I am unable to set an email alias in an Azure Runbook

Eric Neiner 51 Reputation points
2023-03-26T15:41:22.7766667+00:00

I have a need to create email aliases for exchange accounts. I am attempting to do this with an Azure Automation Runbook.

Connect-ExchangeOnline -ManagedIdentity -Organization "myorg.onmicrosoft.com" 
# Interact with query parameters or the body of the request.
$name = $Request.Query.Name
if (-not $name) {
    $name = $Request.Body.Name
}
$user = $Request.Query.User
if (-not $user) {
    $user = $Request.Body.User
}
Get-Mailbox -Identity $name | Format-List  
#Set-Mailbox $user -EmailAddresses @{add="{"+$name+"@myorg.com"}

Get-Mailbox is working but set-mailbox is failing with Failed (Unauthorized).

I have a managed service account with Exchange online permissions. Which I know is working because Get-Mailbox is working.

Does anyone know what permissions need to be set on this to allow this from set-mailbox Azure powershell in this scenario?

Microsoft Exchange Online
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,257 questions
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,578 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,595 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sedat SALMAN 14,065 Reputation points MVP
    2023-03-26T15:55:15.4733333+00:00

    you need to assign the "Exchange Recipients Management" role, which grants the necessary permissions to modify mailbox properties, including email addresses.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.