0

Background

I have a requirement to restore a snapshot of a server daily into a testing environment, once restored, it is necessary to update numerous bits of configuration to make it a test environment. I have managed to update all of the settings I need with one exception, the Port on which the SMTP server is running.

The server is a Windows 2012 R2 server, all of the websites it hosts are running on IIS8, while the SMTP server is running in IIS6, the compatibility packs, WMI extensions are all installed (although the later via the update script).

The issue is I cannot find a way to update the SMTP inbound port from port 25 via a script.

The rest of my update script is written in Powershell, if possible, I would like to remain in powershell to make the changes.

I have tried using appcmd, but cannot find a relevant setting to update, the same with WMI, I have manually changed the SMTP port to try to locate a field to update but this has so far proved of no luck.

Any help that can be given would be greatly appreciated.

Rob

UPDATE

OK, so I actually managed to solve this myself :)

$Serverbindings = (gwmi -namespace root\microsoftiisv2 -class iissmtpserversetting)
$Bindings = $ServerBindings.ServerBindings
foreach ($Binding in $bindings) {
$Binding.Port = "2525"
} 
$Serverbindings.ServerBindings = $Bindings
$ServerBindings.Put()

In case this is useful to anyone else in the future.

  • I have managed to make this work! $Serverbindings = (gwmi -namespace root\microsoftiisv2 -class iissmtpserversetting) $Bindings = $ServerBindings.ServerBindings foreach ($Binding in $bindings) { $Binding.Port = "2525" } $Serverbindings.ServerBindings = $Bindings $ServerBindings.Put() In case this is useful to anyone else in the future. – RobT Sep 9 '16 at 10:43
  • write it as an answer and accept it please. That will fit the site format, ensure the question is closed and filed appropriately and hopefully help others in the future :-) – BlueCompute Sep 9 '16 at 10:47
3

OK, so I actually managed to solve this myself :)

$Serverbindings = (gwmi -namespace root\microsoftiisv2 -class iissmtpserversetting)
$Bindings = $ServerBindings.ServerBindings
foreach ($Binding in $bindings) {
$Binding.Port = "2525"
} 
$Serverbindings.ServerBindings = $Bindings
$ServerBindings.Put()

In case this is useful to anyone else in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.