none
Where can I get help understanding the relevant issues regarding shutdown and startup scripts?

    Question

  • Hello,

    Win 8.1, Server 2012, powershell scripts, system.net.mail (or SMTP mail packet transmission)

    I have been trying for several days to be certain I understand how to reliably transmit an email during OS shutdown and startup.  I've made progress which I'll list below, but I'm still missing some key concepts.  I haven't yet found the online articles I need that communicate all the information that applies.

    What I want to do in a nutshell is:

    1) During shutdown, before SMTP message transmission is no longer available, send an email using the powershell cmdlet Send-MaliMessage.

    2) During startup, after SMTP message transmission is guaranteed available, send an email using the same powershell cmdlet.

    I need to have a dialogue with someone who can take a look at what I've done, how I'm thinking, and simply point out where my misunderstandings are.  I would not have thought this would be so difficult, but a lot has changed from the early days of writing startup and shutdown scripts.

    I have successfully:

    1) Created a powershell script that sends a packet to my hosting provider's email server and sends my email (I.E., I don't think I need help writing the script.  I need help understanding how, when and where to apply the script during shutdown and startup.)

    2) I seem to be able to do this reliably for startup using the startup folder, but it is still troubling that I can't do this reliably using either Local Policies or the Task Scheduler.  I'd like to understand this.  I have also scheduled a task based on one particular event during startup that seems to work for the startup email, but I don't understand how to find an event to send the shutdown email, and I don't understand the whole concept of 'piggy-backing' my script off of some selected event that's not clearly identified in the shutdown/startup process.  I would have thought there should be a clear event that signifies the beginning of shutdown and startup, but I don't see it.  While I also would have thought the Local Policy editor was the place to do this, as the next point makes, the policy editor isn't working for me either.

    3) I can use the Local Policy editor to send an email on Logoff, but I need it for machine shutdown, and the same powershell script that works in the Local Policy editor for Logoff does not work for machine shutdown.  I'm assuming it's because at that point SMTP transmission is no longer possible.  But I need help with that.  That same script also does not work in the machine startup node of the Local Policy editor

    So, I'm looking for the right forum to get in touch with those who are knowledgeable in the shutdown/startup sequence.  I tried asking in the scripting forum, but to date the responses have not really addressed my question.

    Thanks for any direction you can suggest.

    Tuesday, May 05, 2015 2:19 PM

Answers