Send alert for Windows Service Error

First, we need to create the Powershell script (Source from HowToGeek.com):

$EmailFrom = "emailID@emaildomain.com"
$EmailTo = "destination@somedomain.com"
$Subject = "The subject of your email"
$Body = "What do you want your email to say"
$SMTPServer = "smtp.email.server.address"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("usr", "pass");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

Then we need a script to invoke the powershell script

powershell & "C:\PathToPowerShellScript\myPowerShellEmailScript.ps1"

Finally, modify the service to execute a command on failure:

SC failure serviceName command="C:\PathToBat\MyScript.bat"

Advertisements

Bootable ISO to External Drive

  1. Format the drive
    • Run CMD as Administrator
    • diskpart
    • list disk (or list volume to identify the drive by volume number)
    • select disk # (or select volume #)
    • Note: this will remove all data and partitions from the drive. Be careful not to run this on the wrong directory.clean
    • create partition primary
    • format fs=ntfs quick
    • assign
    • exit
  2. Mount the ISO as a virtual drive
  3. Make the external drive bootable (assumptions, Virtual Drive is V: and External Drive is X:
    • V:
    • cd boot
    • bootsect.exe /nt60 X:
  4. Copy the installer files xcopy V:\*.* X: /e /f /h