How to update the HPE iLO Alertmail settings using PowerShell

Here is a quick script you can use to update multiple HPE iLO instances at once with updated Alertmail settings

$InputFile = "C:\Temp\HPEServers.csv"
$MyHPEFile = Import-CSV $InputFile
$credential = Get-Credential
$emailServer = "email.amazonaws.com"
$AlertMailEmail = "group@mycompany.com"
$smtpuser = "key"
$smtppass = "key"
foreach ($HPServer in $MyHPEFile) {
    $Server = $HPServer.ServersiLO
    $connection = Connect-HPEiLO -Credential $credential -DisableCertificateAuthentication -IP $Server
    $domain = Get-HPEiLOServerInfo -Connection $connection | select -ExpandProperty Servername
    $domainfull = $domain + "@mycompany.com"
    Set-HPEiLOAlertMailSetting -Connection $connection -AlertMailEmail $AlertMailEmail -AlertMailEnabled Yes -AlertMailSenderDomain "$domainfull" -AlertMailSMTPServer $emailServer -AlertMailSMTPPort 587 -AlertMailSMTPAuthEnabled Yes -AlertMailSMTPAuthUser $smtpuser -AlertMailSMTPAuthPw $smtppass -AlertMailSMTPSecureEnabled Yes -Force
} 

 

The csv file should appear as:

ServersiLO

192.168.0.1

192.168.0.2

192.168.0.3

Leave a Reply

Your email address will not be published. Required fields are marked *