Office365

הפעלת External Forwarding

הנהלת האתר לא תישא באחריות לכל נזק שייגרם מעבודה לפי מדריך זה. המשתמש נושא באחריות הבלעדית לכל שינוי ועבודה שבוצעה. אין לראות בדברים משום המלצה.

בשבוע שעבר הופעלה ב-365 האפשרות למנוע מתיבות לבצע העברה של External Forwarding לכתובת מייל מחוץ לארגון, דבר שמנע גם ממשתמשים בתוך הארגון מלשלוח אל תיבה שבתוך הארגון, ולקבל Reject לא ברור. הנה כיצד משנים זאת:

מתחילים

בטרם נתחיל, חשוב להבין שמדובר בפיצ’ר אבטחה שלדברי מיקרוסופט מאבטח את התיבה מפריצה אליה. פיצ’ר שמיקרוסופט החליטה להטמיע ב-365 מבלי להודיע על כך ללקוחות.

להלן התוצאה המופיעה אצל השולח כאשר הוא בא לשלוח מייל אל תיבה שמבצעת External Forwarding:

Delivery has failed to these recipients or groups:

office@rd.com
Your message wasn't delivered because the recipient's email provider rejected it.

Diagnostic information for administrators:

Generating server: AVSXVS3PR1001MASD280.EURPRD12.PROD.OUTLOOK.COM
office@rd.com
Remote Server returned '550 5.7.520 Access denied, Your organization does not allow external forwarding. Please contact your administrator for further assistance. AS(7555)'
Original message headers:

אז איך משנים?

הולכים אל הכתובת: https://security.microsoft.com/antispam?rfr=scc_antispam

בחלונית הבאה נלחץ פעמיים על Anti-spam outbound policy (Default)

בחלונית שנפתחה יש לגלול מטה וללחוץ על Edit Protection settings

בחלונית הבאה נסמן את On – Forwarding is enabled ונלחץ על Save

במידה וקופצת השגיאה הבאה יש לסמן Yes

במידה ולאחר מכן מתקבלת השגיאה הבאה יש ללחוץ על OK ולהמשיך לשיטת ה-Powershell

ביצוע באמצעות Powershell

במידה והשיטה מעלה לא עובדת יש לבצע עם הסקריפט הבא (מכיל פתיחת 365 דרך Powershell):

Set-ExecutionPolicy RemoteSigned
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module ExchangeOnlineManagement
Connect-ExchangeOnline
Get-OrganizationConfig | fl Identity, IsDehydrated
Enable-OrganizationCustomization

Connect-ExchangeOnline
Set-HostedOutboundSpamFilterPolicy -identity Default -AutoForwardingMode ON

תודה רבה לנתן-אור המקסים שמדיר שינה מעיניו לטובת קוד איכותי למשתמשים

טיפ קטן

ה-Best Practice של מיקרוסופט לגבי ההגדרה הזו הוא:

ליצור קבוצה ולהכניס אליה את המשתמשים שמבצעים External Forwarding, ולהפעיל את ההגדרה הזו על הקבוצה המצומצמת הזו.

על מנת למצוא ולייצא רשימת תיבות המעבירות מיילים אל כתובת מייל מחוץ לארגון, יש לפתוח Powershell של 365 ולהכניס את הפקודה הבאה:

Get-Mailbox | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward | Export-Csv -Path .\report.csv

יצירת כלל חדש

הסקריפט הבא בודק את התיבות אם מוגדר עליהן העברת מיילים החוצה ולאיזה כתובות:

בדיקת תיבות אם הן מעבירות מיילים החוצה

הסקריפט הבא בודק את התיבות אם מוגדר עליהן העברת מיילים החוצה ולאיזה כתובות:

Get-Mailbox | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward

ניתן כמובן לייצא את המידע ל-CSV:

Get-Mailbox | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward | Export-csv .\users.csv -NoTypeInformation

בדיקת תיבה בודדת אם היא מעבירה מיילים החוצה

הסקריפט הבא בודק תיבה בודדת אם מוגדר עליהן העברת מיילים החוצה ולאיזה כתובות (כאשר david הוא השם הפרטי של העובד):

Get-Mailbox david | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAndForward

בדיקת תיבות עם External Forwarding

הסקריפט הבא בודק את התיבות אם מוגדר עליהן External Forwarding ומייצא את התוצאות לקובץ CSV:

$credential = Get-Credential
Connect-MsolService -Credential $credential
$customers = Get-msolpartnercontract
foreach ($customer in $customers) {
 
    $InitialDomain = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.IsInitial -eq $true}
     
    Write-Host "Checking $($customer.Name)"
    $DelegatedOrgURL = "https://outlook.office365.com/powershell-liveid?DelegatedOrg=" + $InitialDomain.Name
    $s = New-PSSession -ConnectionUri $DelegatedOrgURL -Credential $credential -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection
    Import-PSSession $s -CommandName Get-Mailbox, Get-AcceptedDomain -AllowClobber
    $mailboxes = $null
    $mailboxes = Get-Mailbox -ResultSize Unlimited
    $domains = Get-AcceptedDomain
 
    foreach ($mailbox in $mailboxes) {
 
        $forwardingSMTPAddress = $null
        Write-Host "Checking forwarding for $($mailbox.displayname) - $($mailbox.primarysmtpaddress)"
        $forwardingSMTPAddress = $mailbox.forwardingsmtpaddress
        $externalRecipient = $null
        if($forwardingSMTPAddress){
                $email = ($forwardingSMTPAddress -split "SMTP:")[1]
                $domain = ($email -split "@")[1]
                if ($domains.DomainName -notcontains $domain) {
                    $externalRecipient = $email
                }
 
            if ($externalRecipient) {
                Write-Host "$($mailbox.displayname) - $($mailbox.primarysmtpaddress) forwards to $externalRecipient" -ForegroundColor Yellow
 
                $forwardHash = $null
                $forwardHash = [ordered]@{
                    Customer           = $customer.Name
                    TenantId           = $customer.TenantId
                    PrimarySmtpAddress = $mailbox.PrimarySmtpAddress
                    DisplayName        = $mailbox.DisplayName
                    ExternalRecipient  = $externalRecipient
                }
                $ruleObject = New-Object PSObject -Property $forwardHash
                $ruleObject | Export-Csv C:\temp\customerExternalForward.csv -NoTypeInformation -Append
            }
        }
    }
}

לחלופין ניתן להשתמש בסקריפט המקיף הבא על מנת לבדוק תיבות שמעבירות מיילים אל External Mailboxes.

התוצאה:

Admin

איש סיסטם ואבטחת מידע. אוהב בירה מסוג Corona, וויסקי Crown Royal, גיימר בדם, ובעל חוש הומור.

מאמרים קשורים

Leave a Reply

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

אתה תאהב גם את זה
Close
Back to top button