Sal Gallagher (ARMY-AMC) asked a question.

I have a PowerShell script that checks for website availability and run it from a task. How do I pass the results to an email?

The script runs by it self with the correct status code and message with website up or down. I have a task that runs the script. How do I send an email with the correct message? I have it setup with on success or on failure, send the correct email message. However, since the script runs successfully with website up or down, it will only email on success. How do I send the email that its down?


  • John Curtiss (i hate the web admin)

    obligatory unhelpful forum response: "why are you monitoring a website with file transfer software? you could just run a windows scheduled task on any server anywhere."

     

    with that out of the way:

     

    1. inside your powershell script, use send-mailmessage to only send the email if the website is down.
    2. inside your powershell script, create a new custom moveit task parameter, and pass it the value of your website test. then in the moveit task, use if/then logic to only send an email if that parameter matches a certain value.

     

    in the powershell script:

     

    $mySiteStatus= [whatever the result of your powershell website test is]

    $miaclient.MISetTaskParam("SiteStatus",$mysitestatus) #sitestatus is the parameter name we're passing to the task

     

    in the moveit task, call the new parameter with [parm:(parametername)] syntax:

     

    if [parm:sitestatus] matches "[whatever the bad/down value is from your script]"

    --send email