Powershell script to change SMTP configuration


  • Hi!

    I have a powershell script which I'm using to set up a number of identical Server 2008 R2 boxes.  We have the microsoft SMTP service installed (as "virtual server #1") but I can't find Powershell code to change the properties such that the SMTP service (which can only be manipulated via IIS 6 manager) allows the local system to relay through it.  We have both an application (and the PS script) that need to be able to send emails, but it only works if we set the local relay to be allowed.

    Security is not an issue on the open relay.

    I've seen references to VB, and even one to a purchasable cmdlet - neither of which are really options.


    Thanks in advance!


    Thursday, August 11, 2011 9:23 PM

All replies


    If that doesn't help, please provide the VB reference, and maybe we can convert it.  As for the cmdlet, I doubt it configures the SMTP service itself...

    Thursday, August 11, 2011 9:47 PM
  • I saw that thread, but it utilizes the VBS script adsutil; I'm *really* trying to avoid going that route.

    I think I may have it.  This uses the ADSI reference mechanism to get and set parameters.  I am testing it right now.

    $SMTPServer = [ADSI]"IIS://localhost/smtpsvc/1"


    $SMTPServer.RelayForAuth = -1


    and that failed.
    I think I need to add an SMTPServer.RelayIPList entry, but it must be in octal if I read correctly.


    Thursday, August 11, 2011 10:06 PM
  • That's not flying, either.  

    The RelayForAuth does check the box in IIS6 manager; but I can't get an entry in to the IP list (although, in theory, I shouldn't have to since the box is checked.)  I'm stumped.


    Thursday, August 11, 2011 11:38 PM