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

  • 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, 2014 at 7:56

2 Answers 2


To Start:

$SMTP.ServerState = 2

To Stop:

$SMTP.ServerState = 4
  • By Mistake you are entered wrong ServerState for START & STOP the SMTP.
    – Optimus
    Feb 14, 2013 at 6:39
  • ServerState 2 For START & ServerState 4 for STOP. Thanks Again....
    – Optimus
    Feb 14, 2013 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, 2017 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, 2017 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. Apr 2, 2019 at 14:41

Actual working answer is here:


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.