7 Replies Latest reply on Dec 12, 2016 12:39 PM by Eric.Hubbard

    IT Scripts Error


      I am trying to write a script that will send out an email using the shavlik console so we can setup notifications better than what Shavlik can does with what is built it.  I wrote a script that will work just fine when I run it on my local machine but when I try to run from the shavlik console i get a error.


      "Error: A command that prompts the user failed because the host program or the command type does not support"


      below is the script that i was able to import



          <stScript uid="Scubbed">



              <author>company name</author>

              <scriptType type="consoleOnly" />


                  <option name="OutputMachineResults" value="true" />

                  <option name="OutputRunResults" value="true" />

                  <option name="CombineOutputFiles" value="false" />

                  <option name="DeleteMachineFiles" value="false" />




                  <purpose>Send email notifications</purpose>







                      <description>The reciptant of the email</description>





                      <description>The subject of the email</description>





                      <description>The message body of the email</description>







      function sendMail{



          Param (







           Write-Host "Sending Email"



           #SMTP server name

           $smtpServer = "SMTPSERVER"



           #Creating a Mail object

           $msg = new-object Net.Mail.MailMessage



           #Creating SMTP server object

           $smtp = new-object Net.Mail.SmtpClient($smtpServer)



           #Email structure

           $msg.From = "fromaddress@domain.com"

           $msg.ReplyTo = "replytoaddress@domain.com"


           $msg.subject = $subject

           $msg.body = $body




           #Sending email






      Sendmail -to $to -subject $subject -body $body




      Is there something I am doing wrong.  I have tried this several different ways and it simply doesn't seem to work but I can run it from the local windows server just not inside the application of shavlik.

        • 1. Re: IT Scripts Error
          Recursion SupportEmployee



          Write-Host is unfortunately an unsupported command for ITScripts. The following line:


          "Write-Host "Sending Email""


          Will cause an error.


          There are a few commands that are unsupported in the Protect's ITScripts environment. They are:






          • 2. Re: IT Scripts Error

            I removed that line as it really didn't do anything for me.  I am now getting an error saying  Error: Exception Calling "Send" with "1" argument(s): "Failure Sending mail."


            Do you know why I would be getting this or is there some place that I can actually see the powershell output to see what it is actually doing?

            • 3. Re: IT Scripts Error
              Recursion SupportEmployee

              You can check under C:\ProgramData\Landesk\Shavlik Protect\ITScriptsOutput


              There will be folders named by the target (in this case, MyMachine) and the date and time of the operation. Inside of that should be macineError.txt


              I was able to get your script to import and successfully send an email, however, I had some issues with using our smtp server here to send an email to an address that isn't our domain. If you weren't already, I'd try making the "to" address one on your domain, or you might get a "5.7.1 Unable to Relay" response.


              I also removed the ReplyTo attribute on the mailmessage object, as I didn't have a use for it. This shouldn't impact the send operation though.

              • 4. Re: IT Scripts Error
                Recursion SupportEmployee

                In the off chance you're trying this on a non business network, like if you're working from home, the operation is almost guaranteed to fail due to most ISP's blocking outbound port 25 on non business lines.

                • 5. Re: IT Scripts Error

                  So I am doing this on our business network.  The to address is also my business email so everything should be internal so we shouldn't have a port issue. 


                  Does the version of powershell matter?  I developed the script in powershell 5 and right now the server has powershell 4 on it.  wouldn't that have anything to do with it?  I just am not sure how the Shavlik console uses the powershell command prompt?

                  • 6. Re: IT Scripts Error
                    Recursion SupportEmployee

                    The version shouldn't matter. Your script runs in Powershell 4, so there aren't any command compatibility issues.


                    The error output should give you more information.

                    • 7. Re: IT Scripts Error

                      Sorry I was sending to the wrong relay server.  I corrected that everything is now working.


                      Thanks for your help with this.  This will really help us in our automation.