получить-карантин сообщений в Azure автоматизации - PullRequest
1 голос
/ 23 февраля 2020

Если я попробую приведенный ниже скрипт в Azure Automation, я получу ошибку Get-QuarantineMessages не распознана ...

Этот командлет не работает в Azure Automation?

 $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 https://outlook.office365.com/powershell-liveid/ -Credential $ Cred -Аутентификация Basi c -AllowRedirection -Name $ ConnectionName Import-Module (Import-PSSession -Session $ ExchangeOnlineSession -AllowClobber -DisableNameChecking) -Global

    $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
...