Net stop/start W3SVC and Stop/Start-Service W3SVC vs IISRESET STOP/START
I encountered a problem where I wanted to stop and start IIS by using either the command line or powershell versions of stopping and starting IIS.
NET STOP W3SVC
NET START W3SVC
Both of those stopped and started the World Wide Publishing service correctly. But both appeared to not stop/recycle the worker processes. With Net start and stop giving an error message when IIS was already stopped and/or started before running those commands, resulting in a scheduled task error code.
I found that using the IISRESET command, it does close those worker processes and when IIS was already stopped and/or started it didn’t return an error, thus resulting in the scheduled task returning a nice 0x0 (success)
Thus: use the following commands (also within powershell) if you want to stop/start IIS websites. This will always work as intended and not return an error code (in some cases, where the others would)