{"id":77,"date":"2014-05-22T16:36:20","date_gmt":"2014-05-22T08:36:20","guid":{"rendered":"http:\/\/kylemcdonald.com.au\/?p=77"},"modified":"2018-08-14T00:37:25","modified_gmt":"2018-08-13T16:37:25","slug":"powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2","status":"publish","type":"post","link":"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/","title":{"rendered":"Powershell script to get a unique list of IP’s added to Exchange 2013 Receive Connectors"},"content":{"rendered":"

Powershell script that allows you to get a list of all IP’s allowed to relay across all Relay Receive Connectors in your Exchange 2013 environment, and saves them to a text file for review. This is not a very elegant method, but it does the job for now.<\/p>\n

<\/p>\n

<#\r\n.Name\r\n        Get-RelayIPUnique-Exchange2013.ps1\r\n.Description\r\n        Powershell script that allows you to get a list of all IP's allowed to relay across all Relay Receive Connectors in your Exchange environment.\r\n.Parameters\r\n        None - execute directly from the Exchange Management Shell.\r\n.Version\r\n        0.2\r\n.Author\r\n        Kyle McDonald\r\n.Compatibility\r\n        Exchange 2013\r\n.Release Date\r\n        May 2015\r\n.Notes\r\nChange Log\r\nV0.1, 22\/05\/2015 - Initial version\r\nV0.2, 19\/06\/2015 - Added variables for Current_Date & Output_Filename\r\n#>\r\n \r\n# Define Variables\r\n$Script_Name = $MyInvocation.MyCommand.Name\r\n$Current_Date = get-date -format yyyyMMdd\r\n$Output_Filename = (Get-Childitem $Script_Name).basename + \"-Log-\" + $Current_Date + \".txt\"\r\n \r\n# Get a list of all IP's from ReceiveConnectors with \"Relay\" in their name\r\n$FormatEnumerationLimit =-1\r\nGet-ReceiveConnector | Where {$_.identity -like \"*relay*\"} | Select-Object -Property 'Identity','RemoteIPRanges' | FL > $Output_Filename\r\n \r\n# Remove lines starting with \"Identity\"\r\n(Get-content $Output_Filename) | select-string -pattern 'Identity' -notmatch | Out-File $Output_Filename\r\n \r\n# replace \"RemoteIPRanges : {\" with newline\r\n(Get-Content $Output_Filename) | Foreach-Object {$_ -replace \"RemoteIPRanges : \\{\", \"`n\"} | Set-Content $Output_Filename\r\n \r\n# replace \", \" with newline\r\n(Get-Content $Output_Filename) | Foreach-Object {$_ -replace \", \", \"`n\"} | Set-Content $Output_Filename\r\n \r\n# replace \"}\" with newline\r\n(Get-Content $Output_Filename) | Foreach-Object {$_ -replace \"\\}\", \"`n\"} | Set-Content $Output_Filename\r\n \r\n# replace leading blank spaces on all lines (17 spaces) with newline\r\n(Get-Content $Output_Filename) | Foreach-Object {$_ -replace \"                 \", \"`n\"} | Set-Content $Output_Filename\r\n \r\n# sort lines, case insensitive\r\n(Get-content $Output_Filename) | sort | get-unique > $Output_Filename\r\n \r\n# remove any blank lines\r\n(Get-content $Output_Filename) | ? {$_.trim() -ne \"\" } | set-content $Output_Filename\r\n \r\n# Done\r\nWrite-Host \"\"\r\nWrite-Host \"Done! Opening file: $Output_Filename\" -ForegroundColor Cyan\r\nWrite-Host \"\"\r\nInvoke-Item $Output_Filename\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Powershell script that allows you to get a list of all IP’s allowed to relay across all Relay Receive Connectors in your Exchange 2013 environment, and saves them to a text file for review. This is not a very elegant Continue reading Powershell script to get a unique list of IP’s added to Exchange 2013 Receive Connectors<\/span>→<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[30],"tags":[],"yoast_head":"\nPowershell script to get a unique list of IP's added to Exchange 2013 Receive Connectors - Kyle McDonald<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Powershell script to get a unique list of IP's added to Exchange 2013 Receive Connectors - Kyle McDonald\" \/>\n<meta property=\"og:description\" content=\"Powershell script that allows you to get a list of all IP’s allowed to relay across all Relay Receive Connectors in your Exchange 2013 environment, and saves them to a text file for review. This is not a very elegant Continue reading Powershell script to get a unique list of IP’s added to Exchange 2013 Receive Connectors→\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Kyle McDonald\" \/>\n<meta property=\"article:published_time\" content=\"2014-05-22T08:36:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-13T16:37:25+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@KarmicIT\" \/>\n<meta name=\"twitter:site\" content=\"@KarmicIT\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kylemcdonald.com.au\/#website\",\"url\":\"https:\/\/kylemcdonald.com.au\/\",\"name\":\"Kyle McDonald\",\"description\":\"Perth-based IT enthusiast\",\"publisher\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/#\/schema\/person\/f3fe27d0e0f57ef43e2444fbe8989906\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/kylemcdonald.com.au\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-AU\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/#webpage\",\"url\":\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/\",\"name\":\"Powershell script to get a unique list of IP's added to Exchange 2013 Receive Connectors - Kyle McDonald\",\"isPartOf\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/#website\"},\"datePublished\":\"2014-05-22T08:36:20+00:00\",\"dateModified\":\"2018-08-13T16:37:25+00:00\",\"inLanguage\":\"en-AU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/#webpage\"},\"author\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/#\/schema\/person\/f3fe27d0e0f57ef43e2444fbe8989906\"},\"headline\":\"Powershell script to get a unique list of IP’s added to Exchange 2013 Receive Connectors\",\"datePublished\":\"2014-05-22T08:36:20+00:00\",\"dateModified\":\"2018-08-13T16:37:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/#\/schema\/person\/f3fe27d0e0f57ef43e2444fbe8989906\"},\"articleSection\":\"Scripting\",\"inLanguage\":\"en-AU\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kylemcdonald.com.au\/2014\/05\/22\/powershell-script-to-get-a-unique-list-of-ips-added-to-exchange-2013-receive-connectors-2\/#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/kylemcdonald.com.au\/#\/schema\/person\/f3fe27d0e0f57ef43e2444fbe8989906\",\"name\":\"Kyle McDonald\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/kylemcdonald.com.au\/#personlogo\",\"inLanguage\":\"en-AU\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/74b24af47c7a561be463563db3fa821c?s=96&d=mm&r=g\",\"caption\":\"Kyle McDonald\"},\"logo\":{\"@id\":\"https:\/\/kylemcdonald.com.au\/#personlogo\"},\"sameAs\":[\"http:\/\/au.linkedin.com\/in\/karmicit\",\"https:\/\/twitter.com\/KarmicIT\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/posts\/77"}],"collection":[{"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":4,"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":254,"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/posts\/77\/revisions\/254"}],"wp:attachment":[{"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kylemcdonald.com.au\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}