在Azure自动化中获取隔离消息
如果我在Azure Automation中尝试下面的脚本,我会得到错误get QuarantineMessages不可识别 此cmdlet在Azure Automation中不起作用在Azure自动化中获取隔离消息,azure,automation,exchange-server,Azure,Automation,Exchange Server,如果我在Azure Automation中尝试下面的脚本,我会得到错误get QuarantineMessages不可识别 此cmdlet在Azure Automation中不起作用 $MyCredential = "O365Credential" $subject = "Mail send from Azure Automation using Office 365" $userid='xistoso@xistoso.ca' # Get the PowerShell creden
$MyCredential = "O365Credential"
$subject = "Mail send from Azure Automation using Office 365"
$userid='xistoso@xistoso.ca'
# Get the PowerShell credential and prints its properties
$Cred = Get-AutomationPSCredential -Name $MyCredential
if ($Cred -eq $null)
{
$Body = Write-Output "Credential entered: $MyCredential does not exist in the automation service. Please create one `n"
}
else
{
$ExchangeOnlineSession=New PSSession-ConfigurationName Microsoft.Exchange-ConnectionUri-Credential$Cred-Authentication Basic-AllowDirection-Name$ConnectionName
导入模块(导入PSSession-会话$ExchangeOnlineSession-AllowClobber-DisableNameChecking)-全局
$today=获取日期
$Dayed=(获取日期).AddHours(-1)
$Body=获取检疫信息-入站方向-StartReceivedDate$昨天-EndReceivedDate$今天
}
发送邮件至'xisto@xisto.com'-Subject$Subject-Body$Body-usesssl-Port 587-SmtpServer'smtp.office365.com'-From$userid-BodyAsHtml-Credential$Cred
写入输出“邮件现在已发送`n”
写入输出“--------------------------------------------------------------”
删除PSSession$ExchangeOnlineSession
$today = get-date
$yesterday = (get-date).AddHours(-1)
$Body = Get-QuarantineMessage -Direction Inbound -StartReceivedDate $yesterday -EndReceivedDate $today
<#$CredUsername = $Cred.UserName
$CredPassword = $Cred.GetNetworkCredential().Password
Write-Output "-------------------------------------------------------------------------"
Write-Output "Credential Properties: "
Write-Output "Username: $CredUsername"
Write-Output "Password: *************** `n"
Write-Output "-------------------------------------------------------------------------"
# Write-Output "Password: $CredPassword `n" 3#>
}
Send-MailMessage -To 'xisto@xisto.com' -Subject $subject -Body $Body -UseSsl -Port 587 -SmtpServer 'smtp.office365.com' -From $userid -BodyAsHtml -Credential $Cred
Write-Output "Mail is now send `n"
Write-Output "-------------------------------------------------------------------------"
Remove-PSSession $ExchangeOnlineSession