Adding or Removing Domains in Exchange Server 2007

by Christian Haberl März 25, 2008 10:46

I have an Exchange Server that forwards a large number of domains to a smart host using a send connector. I have written 2 little powershell scripts to add or remove these domains from my Exchange configuration. The tricky part was the "AddressSpaces" of the "Set-Sendconnector" but I think I've found a pretty nice solution.

AddExtDomain.ps1

Param(
    [string] $DomainName
)

new-AcceptedDomain -Name $DomainName -DomainName $DomainName -DomainType 'ExternalRelay'
new-RemoteDomain -Name $DomainName -DomainName $DomainName
$a = (Get-SendConnector "Smart Host Sendmail").AddressSpaces
$a += $DomainName
Set-SendConnector "Smart Host Sendmail" -AddressSpaces $a

RemExtDomain.ps1

Param(
    [string] $DomainName
)

Remove-RemoteDomain -Identity $DomainName -confirm:$false
Remove-AcceptedDomain -Identity $DomainName -confirm:$false

$a = (Get-SendConnector "Smart Host Sendmail").AddressSpaces | where {$_.Domain -ne $DomainName}

Set-SendConnector "Smart Host Sendmail" -AddressSpaces $a

 

If you want to add multiple domains at a time, this solution, using import from a csv-file, is better for you:

To get the right format for the CSV file, one can export the current domains using this script:

ExpExtDomains.ps1

(Get-SendConnector "Smart Host Sendmail").AddressSpaces | Export-Csv AddressSpaces.csv

 
This is what the list will look like. Now I can modify the list by replacing the values with my new domains.

Finally, to import domains from that list, I use this script:

ImpExtDomains.ps1

import-csv AddressSpaces.csv | % { new-AcceptedDomain -Name $_.Domain -DomainName $_.Domain -DomainType 'ExternalRelay' }
import-csv AddressSpaces.csv | % { new-RemoteDomain -Name $_.Domain -DomainName $_.Domain }
$a = (Get-SendConnector "Smart Host Sendmail").AddressSpaces
import-csv AddressSpaces.csv | % { $a += $_.Domain }
Set-SendConnector "Smart Host Sendmail" -AddressSpaces $a

To confirm the settings:
Get-AcceptedDomain
Get-RemoteDomain
(Get-SendConnector "Smart Host Sendmail").AddressSpaces

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

Exchange Server

Kommentare

26.11.2010 04:58:57 #

Carroll B. Merriman

I cant believe the quantity of fantastic info you have on your weblog. I have learned a lot from it. Will be coming back soon…

Carroll B. Merriman United States

06.10.2011 09:50:32 #

over the hill party/over the hill party supplies

Undeniably believe that which you stated. Your preferred validation seemed to be on the web the easiest thing to understand. I say to you, I certainly get annoyed while individuals consider worries that they just donít know about. A person managed to hit the toe nail on the very best in addition to defined the event without having side-effects , individuals can take a signal. Will likely be back to have more. Thanks

over the hill party/over the hill party supplies United States

08.11.2011 15:37:05 #

mason

Most of these websites also offer a wide selection of other downloads including mp3 music for I-pods, TV shows download, free Movie online and a host of many others.

mason United States

17.11.2011 15:17:52 #

Johnathon Ransom

I went over this web site and I believe you have a lot of good info, saved to favorites (:.

Johnathon Ransom United States

22.11.2011 13:38:19 #

Dunia Digital

nice info you got here mate.. keep the nice blogging..

Dunia Digital Türkmenistan

22.11.2011 16:13:21 #

belajar hipnotis

Dead composed subject material, regards for entropy.

belajar hipnotis United States

16.12.2011 18:45:44 #

500 rubles

Hello there, just became alert to your weblog by means of Google, and discovered that it’s truly informative. I’m gonna watch out for brussels. I’ll be grateful in the event you continue this in future. Numerous men and women will probably be benefited from your writing. Cheers!

500 rubles United States

25.12.2011 19:50:14 #

Rob Lardieri

Maybe you have pondered writing a guide or guest authoring on other sites? For sale blog centered on a similar ideas you discuss and would love to acquire you share some stories/information. I realize my visitors would many thanks for work. For anybody who is even remotely interested, twenty-four hours a day shoot me some text.

Rob Lardieri United States

01.01.2012 07:09:55 #

Picking Prudent Programs In female libido enhancement

The therapies that are in put now days all weaken the overall body which incorporates the immune procedure, our complicated built in restore program which keeps us wellbeing and ailment cost-free. It's only when this method had been weakened by our modern-day way of living which has allowed usual body cells to mutate and divide without regulate and turn out to be cancerous.

Picking Prudent Programs In female libido enhancement United States

04.01.2012 22:30:20 #

ninjas

I love the look of this site, it looks very expensive! Is the template a free one or a premium one?

ninjas United States

08.01.2012 23:44:41 #

giovanni

Helpful info. Lucky me I discovered your website by accident, and I am surprised why this twist of fate did not happened in advance! I bookmarked it.

giovanni United States

04.02.2012 23:07:35 #

Russound Safety Guy

Hi! I know this is sort of off-topic but I had to ask. Does building a well-established blog such as yours take a massive amount work? I am brand new to writing a blog but I do write in my journal everyday. I'd like to start a blog so I will be able to share my own experience and views online. Please let me know if you have any kind of suggestions or tips for new aspiring bloggers. Thankyou!

Russound Safety Guy United States

11.03.2012 17:25:43 #

Tifany Straight

Peter  Same thing is happening to me. Have you found a resolution yet? I held the #1 rank for over 3 years and now I don't exist... I'm losing a lot of busines.

Tifany Straight United States

Kommentar schreiben


(Zeigt dein Gravatar icon)

  Country flag

biuquote
  • Kommentar
  • Live Vorschau
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen | Modified by Mooglegiant

Facebook

Über den Autor

MCTS

Christian Haberl Christian Haberl ist seit mehr als 10 Jahren als EDV Berater, Vortragender und Trainer tätig. Er kann sich nicht für ein Spezialgebiet entscheiden, drum heißt dieser Blog auch "Kraut & Rüben Blog" - Unter seine Interessen fallen Web-Entwicklung auf ASP.NET Basis, Information Worker & Productivity Technologien (Windows, Office), Server (Windows Server, Small Business, Virtualisierung, Exchange), Scripting, Spam Filtering/Security und Digital Home. Christian Haberl ist auch einer der führenden Produktspezialisten für Windows Media Center und Windows Home Server und ist Direktor des ClubDigitalHome.
Im Jahr 2008 hat Christian Haberl über 200 Vorträge und Schulungen durchgeführt.
Im Frühjahr 2009 wurde Christian Haberl von Microsoft Österreich zum "Influencer" ernannt, weiters wurde er Microsoft Certified Technology Specialist / Microsoft Certified Connected Home Integrator sowie Microsoft Certified Consumer Sales Specialist.


Netzwerk Management

Bandwidth

RecentComments

Comment RSS