Configuring a global email recipient for all vCenter Server alarms
search cancel

Configuring a global email recipient for all vCenter Server alarms

book

Article ID: 434289

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

Users may wish to configure a single email address to receive all alerts generated by vCenter Server without manually editing every individual alarm definition.

Environment

  • vCenter 7.x
  • vCenter 8.x

Cause

vCenter Server currently does not support a "Global Subscriber" setting. Email notification recipients need to be configured at the action level within each specific alarm definition.

Resolution

There is no global setting for alarm emails.

Configure Mail Server Settings: Ensure vCenter has valid SMTP settings to send emails.

  1. Navigate to vCenter Server > Configure > Settings > General.
  2. Click Edit next to Mail and enter your Mail Server and Mail Sender details.
    For detailed SMTP configuration steps, refer to KB Setting Up Email Notifications for Alarms generated in vCenter Server.

As a workaround, use the below PowerShell script to update the email address for all alarms.

Best practice: Use an Email Distribution List to avoid updating vCenter alarms every time a recipient change is needed.

  1. Ensure you have installed VCF PowerCLI
  2. Ensure you have a working backup of the vCenter Server.
  3. Take a powered off snapshot of the vCenter Server
  4. Use the below example script. Customize the vCenter Server, user, password and Email address.
    # 1. Connect to your vCenter Server
    Connect-VIServer -Server "vcenter.domain.local" -User "[email protected]" -Password "<password>"
    
    # 2. Define the recipient email address
    $emailAddress = "[email protected]"
    
    # 3. Retrieve all alarm definitions
    $alarms = Get-AlarmDefinition
    
    # 4. Loop through all alarms and add the email action
    foreach ($alarm in $alarms) {
        # Check if an email action already exists to avoid duplicate entries
        $existingAction = Get-AlarmAction -AlarmDefinition $alarm -ActionType SendEmail -ErrorAction SilentlyContinue
        
        if (-not $existingAction) {
            Write-Host "Adding email action to: $($alarm.Name)"
            
            # Add the email action
            $action = New-AlarmAction -AlarmDefinition $alarm -Email -To $emailAddress
            
            # Optional: Define exactly when it triggers (e.g., only when changing from Yellow to Red)
            # New-AlarmActionTrigger -AlarmAction $action -StartStatus "Yellow" -EndStatus "Red" | Out-Null
        } else {
            Write-Host "Email action already exists for: $($alarm.Name)"
        }
    }
    
    # 5. Disconnect from vCenter
    Disconnect-VIServer -Confirm:$false