script to add multiple domains in Microsoft Default SMTP Virtual Server

Posted on 2009-04-16
1 Endorsement
Last Modified: 2014-10-17
I am looking for a script that will allow me to add 200+ domains to the Microsoft Default SMTP Virtual Server.

We curretnly have 200+ domains setup in Microsoft SMTP, we are moving to a new colo, and I need to change all these domains from being LOCAL (Alias) to REMOTE.
Getting properties on each one does not allow me to change this.
Looks like I will have to delete all of them and recreate them.
Is there a way to do this through a script? They will all point to the same IP at our new colo.
Question by:kon21
    LVL 37

    Accepted Solution


    use this to extract them all:

    C:\Inetpub\AdminScripts>adsutil enum /SmtpSvc/1/Domain

    You may need to parse them further using some scripting to find out if they are local or remote:

    C:\Inetpub\AdminScripts>adsutil enum /SmtpSvc/1/Domain/
    KeyType                         : (STRING) "IIsSmtpDomain"
    RouteAction                     : (INTEGER) 2

    C:\Inetpub\AdminScripts>adsutil enum /SmtpSvc/1/Domain/
    KeyType                         : (STRING) "IIsSmtpDomain"
    RouteAction                     : (INTEGER) 16

    To add them on the new server, script it using CREATE and SET commands:

    C:\Inetpub\AdminScripts>adsutil create smtpsvc/1/Domain/ "IIsSmtpDomain"
    C:\Inetpub\AdminScripts>adsutil set smtpsvc/1/Domain/ 2

    C:\Inetpub\AdminScripts>adsutil create smtpsvc/1/Domain/ "IIsSmtpDomain"
    C:\Inetpub\AdminScripts>adsutil set smtpsvc/1/Domain/ 16

    Excel is a useful tool to build scripts for this purpose.



    Expert Comment

    by:Jason Morgan
    I needed to import 300 domains into IIS/SMTP and this script was exactly what I needed. Thank you!

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
    Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now