{"id":2165,"date":"2017-10-12T11:06:48","date_gmt":"2017-10-12T11:06:48","guid":{"rendered":"http:\/\/galhano.com\/blog\/?p=2165"},"modified":"2017-10-12T11:17:19","modified_gmt":"2017-10-12T11:17:19","slug":"turn-exchange-anonymous-relay-on-or-off-or-view-connector-status","status":"publish","type":"post","link":"http:\/\/galhano.com\/blog\/?p=2165","title":{"rendered":"Turn Exchange Anonymous Relay On or Off or View Connector Status"},"content":{"rendered":"<p>This EMS script for Exchange 2007-2016 allows Exchange Administrators to toggle anonymous external relay permissions on front-end Receive Connectors. Connectors listed in Yellow allow anonymous SMTP emails to any internal or external recipients. Connectors listed in White only<\/p>\n<p><a class=\"btn btn-default btn-sm\" href=\"http:\/\/galhano.com\/blog\/wp-content\/uploads\/2017\/10\/Toggle-ExternalRelayReceiveConnectors.zip\">Toggle-ExternalRelayReceiveConnectors <i class=\"glyphicon glyphicon-download-alt\"><\/i><\/a><\/p>\n<p>[ps]<\/p>\n<p>C:\\_tmp&gt;.\\Toggle-ExternalRelayReceiveConnectors.ps1<\/p>\n<p>Toggle External Relay<\/p>\n<p>1 &#8211; SRV-EXCH2\\Client Frontend EXSERVER1<br \/>\n2 &#8211; SRV-EXCH2\\Default Frontend EXSERVER1<br \/>\n3 &#8211; SRV-EXCH2\\Outbound Proxy Frontend EXSERVER1<br \/>\nX &#8211; Exit<\/p>\n<p>Which Receive Connector to toggle:<\/p>\n<p>[\/ps]<\/p>\n<p>This EMS script for Exchange 2007-2016 allows Exchange Administrators to toggle anonymous external relay permissions on front-end Receive Connectors. Connectors listed in Yellow allow anonymous SMTP emails to any internal or external recipients. Connectors listed in White only allow SMTP emails to internal recipients. Run this script from the Exchange Management Shell.<\/p>\n<p>See my blog for more information:\u00a0http:\/\/www.expta.com\/2016\/01\/turn-exchange-anonymous-relay-on-or-off.html<\/p>\n<p><!--more--><\/p>\n<p>Thanks to <a id=\"displayName\" class=\"baseball-card-display-name\" title=\"Go to Jeff Guillet [MCSM, MVP, Author, Blogger]'s profile\" href=\"https:\/\/social.technet.microsoft.com:443\/profile\/jeff%20guillet%20%5Bmcsm,%20mvp,%20author,%20blogger%5D\/\" target=\"_blank\" rel=\"noopener\">Jeff Guillet<\/a><\/p>\n<p>https:\/\/gallery.technet.microsoft.com\/Turn-Exchange-Anonymous-5bed81a4<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>[ps]<br \/>\n &lt;# .SYNOPSIS Allows Exchange Admins to toggle anonymous external relay settings on frontend Receive Connectors. Author\/Copyright: Jeff Guillet, MCSM|MVP &#8211; All rights reserved Email\/Blog\/Twitter: jeff@expta.com | www.expta.com | @expta THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER. .NOTES Version 1.0, January 6, 2016 Revision History &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 1.0 Initial release .DESCRIPTION Allows Exchange Admins to toggle anonymous external relay permissions on frontend Receive Connectors. Receive Connectors listed in yellow allow anonymous external relay. This script must be run from the Exchange Management Shell. .LINK http:\/\/www.expta.com\/2016\/01\/turn-exchange-anonymous-relay-on-or-off.html .EXAMPLE PS C:\\&gt;Toggle-ExternalRelayReceiveConnectors.ps1 <\/p>\n<p>The script will list all Receive Connectors in the organization. Connectors listed in Yellow allow anonymous emails to any recipient. Connectors listed in White only allow emails to recipients within the organization. <\/p>\n<p>Select the number of the Receive Connector to toggle or &#8216;X&#8217; to quit.<br \/>\n#&gt; <\/p>\n<p># Get collection of Frontend Transport Receive Connectors<br \/>\n$RCColl = Get-ReceiveConnector | Sort-Object -Property Identity | where {$_.TransportRole -eq &quot;FrontendTransport&quot;} | Select Id <\/p>\n<p># Create an array of the connectors<br \/>\n$RCArray = @()<br \/>\nforeach ($rc in $RCColl) {<br \/>\n    $RCArray += $rc<br \/>\n} <\/p>\n<p>$RCCount = $RCArray.Count <\/p>\n<p>do {<br \/>\n    Write-Host<br \/>\n    Write-Host &quot;Toggle External Relay&quot; -ForegroundColor White<br \/>\n    Write-Host <\/p>\n<p>    # List all each FE Receive Connectors<br \/>\n    for ($i = 1; $i -le $RCCount; $i++) {<br \/>\n        # Check to see if Anonymous\/ms-Exch-SMTP-Accept-Any-Recipient is already set<br \/>\n        if (Get-ReceiveConnector $RCArray[$i &#8211; 1].Id | Get-ADPermission -User &quot;NT Authority\\Anonymous Logon&quot; | where {$_.ExtendedRights -like &quot;ms-Exch-SMTP-Accept-Any-Recipient&quot;}) {<br \/>\n            $color = &quot;Yellow&quot;<br \/>\n        }<br \/>\n        else {<br \/>\n            $color = &quot;White&quot;<br \/>\n        }<br \/>\n        Write-Host (&quot;{0,3} &#8211; {1}&quot; -f $i, $RCArray[$i &#8211; 1].Id) -ForegroundColor $color<br \/>\n    } <\/p>\n<p>    Write-Host &quot;  X &#8211; Exit&quot; -ForegroundColor Red<br \/>\n    Write-Host <\/p>\n<p>    do {<br \/>\n        $choice = Read-Host &quot;Which Receive Connector to toggle&quot;<br \/>\n        $ok = $false<br \/>\n        if ($choice -eq &quot;x&quot; -or $choice -eq &quot;X&quot;) { Exit }<br \/>\n        $ErrorActionPreference = &quot;SilentlyContinue&quot;<br \/>\n        $choice = [int]$choice<br \/>\n        if ($choice -gt 0 -and $choice -le $RCCount) { $ok = $true }<br \/>\n        if ( -not $ok) { Write-Host &quot;* Invalid selection *&quot; -ForegroundColor Red }<br \/>\n    } until ( $ok ) <\/p>\n<p>    # Toggle Anonymous\/ms-Exch-SMTP-Accept-Any-Recipient on or off<br \/>\n    Write-Host &quot;Processing:&quot; $RCArray[$choice &#8211; 1].Id -ForegroundColor Green<br \/>\n    if (Get-ReceiveConnector $RCArray[$choice &#8211; 1].Id | Get-ADPermission -User &quot;NT Authority\\Anonymous Logon&quot; | where {$_.ExtendedRights -like &quot;ms-Exch-SMTP-Accept-Any-Recipient&quot;}) {<br \/>\n        Write-Host &quot;Turning external relay OFF&quot; -ForegroundColor White<br \/>\n        Get-ReceiveConnector $RCArray[$choice &#8211; 1].Id | Remove-ADPermission \u2013User &quot;NT Authority\\Anonymous Logon&quot; \u2013ExtendedRights ms-Exch-SMTP-Accept-Any-Recipient -Confirm:$False<br \/>\n    }<br \/>\n    else {<br \/>\n        Write-Host &quot;Turning external relay ON&quot; -ForegroundColor Yellow<br \/>\n        Get-ReceiveConnector $RCArray[$choice &#8211; 1].Id | Add-ADPermission \u2013User &quot;NT Authority\\Anonymous Logon&quot; \u2013ExtendedRights ms-Exch-SMTP-Accept-Any-Recipient #,ms-Exch-Bypass-Anti-Spam<br \/>\n    }<br \/>\n} until ( $quit )<br \/>\n [\/ps]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This EMS script for Exchange 2007-2016 allows Exchange Administrators to toggle anonymous external relay permissions on front-end Receive Connectors. Connectors listed in Yellow allow anonymous SMTP emails to any internal or external recipients. Connectors listed in White only Toggle-ExternalRelayReceiveConnectors [ps] C:\\_tmp&gt;.\\Toggle-ExternalRelayReceiveConnectors.ps1 Toggle External Relay 1 &#8211; SRV-EXCH2\\Client Frontend EXSERVER1 2 &#8211; SRV-EXCH2\\Default Frontend EXSERVER1 3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"close","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,21,161],"tags":[],"class_list":["post-2165","post","type-post","status-publish","format-standard","hentry","category-code-snippets","category-exchange","category-powershell","author-admin"],"_links":{"self":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2165"}],"version-history":[{"count":7,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2165\/revisions"}],"predecessor-version":[{"id":2173,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2165\/revisions\/2173"}],"wp:attachment":[{"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2165"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/galhano.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}