5

Because of some error on my server, my SMTP service [SMTP Virtual Server #1] stops. I want to create job which will run periodically to check the SMTP server status, if it is stopped then the script will start it again.

I have used Start-Service "SMTPSVC" but it only starts the UATSERV service and not the [SMTP Virtual Server #1] virtual host (please have a look of the attached image).

How do I start the virtual server after the service is started?

My admin team is working on the issue. I wanted to use this temporary solution in the mean time.

Any help is appreciated... :)

SMTP virtual host image

migrated from sharepoint.stackexchange.com Jan 15 '13 at 16:21

This question came from our site for SharePoint enthusiasts.

  • This doesn't actually work, at least in Windows 2008. It puts a Red X over the SMTP server but telnet tests to port 25 show that its not really working, at least not for me – user236516 Aug 7 '14 at 7:56
6

To Start:

$SMTP=[adsi]"IIS://localhost/SMTPSVC/1"
$SMTP.ServerState = 2
$SMTP.SetInfo()

To Stop:

$SMTP=[adsi]"IIS://localhost/SMTPSVC/1"
$SMTP.ServerState = 4
$SMTP.SetInfo()
  • By Mistake you are entered wrong ServerState for START & STOP the SMTP. – Optimus Feb 14 '13 at 6:39
  • ServerState 2 For START & ServerState 4 for STOP. Thanks Again.... – Optimus Feb 14 '13 at 6:40
  • fyi, this doesn't stop/start the server on windows 2012, it only changes the icon this worked for me: $SMTP=[adsi]"IIS://localhost/SMTPSVC/1" $SMTP.Stop() or .Start() – Rogelio Jul 4 '17 at 14:00
  • This did not work for me on Windows Server 2008R2. As above, the status appears to change in IIS Manager, but the actual status of the service is not affected. – andyb Oct 19 '17 at 23:59
  • As a heads-up, I found that the object does not "update" in PowerShell if the state is changed. For example, if $SMTP.ServerState is 2, then you use $SMTP.Stop() or stop it externally, then $SMTP.ServerState will STILL BE 2. You have to re-initialize $SMTP again to get the accurate state again. – Demonslay335 Apr 2 at 14:41
1

Actual working answer is here:

([ADSI]'IIS://LOCALHOST/SMTPSVC/1').Start()
([ADSI]'IIS://LOCALHOST/SMTPSVC/1').Stop()

From: https://stackoverflow.com/a/37432396/3321505

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.