我有一个 powershell 脚本,它将获取我所有的 azure 应用程序注册信息并通过电子邮件发送信息。我的笔记本电脑上有 powershell,但无法在 Azure 自动化中发送电子邮件。
这是我在 Azure 自动化中遇到的错误。我替换了我的 smtp 服务器名称。有一个实际的服务器不是那个值。我所有的变量都被填充了。同样,这是在我的笔记本电脑上使用自动化中完全相同的脚本工作的。
无法解析远程名称:'smtpserver'
这是它的代码片段
#Send Email
$Style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$Style += "TABLE{border: 1px solid black; border-collapse: collapse;}"
$Style += "TH{border: 1px solid black; background: #D8D8D8; padding: 5px; }"
$Style += "TD{border: 1px solid black; padding: 5px; }"
$Style += "</style>"
$Html = ''
$Html += "<div>These application security items are expiring in $($ExpiresInDays) days</div>"
$Html += "<br></br>"
$Html += $ExpiringTable | ConvertTo-Html -Head $Style
$html += "<br></br>"
$Html += "For troubleshooting this email, the automation for this can be found at this location: "
$Html += "<a href="+ $($AutomationLink) +">Azure Portal: Expiring Security Items</a>"
Send-MailMessage -SmtpServer $SmtpServer -From $EmailFrom -To $EmailTo -Subject $Subject -Body $Html -BodyAsHtml -Priority $Priority -ErrorAction Stop