Optimizing Invoke-WebRequest and email script.

Welcome Forums General PowerShell Q&A Optimizing Invoke-WebRequest and email script.

Viewing 1 reply thread
  • Author
    Posts
    • #244898
      Participant
      Topics: 4
      Replies: 9
      Points: 71
      Rank: Member

      Hi

      I am pretty new to PowerShell but have made some pretty handy routines so far.
      They are pretty simple, and I was hoping that maybe someone in here could help me optimize this routine I am using to download a .zip file, and then emailing it.

      The scripts run every time, but once in a while, the attached file in the email is missing?
      Not sure why, because my routines generate no logs, so maybe I should start there.
      al I think that I should add some sort of – If the email does not contain the attached file, try again or something like that.

      Let me hear you thought about, what you would add in a routine like the one in my example?

    • #244946
      Participant
      Topics: 8
      Replies: 568
      Points: 2,171
      Helping Hand
      Rank: Community Hero

      First off, if there isn’t a very good, specific reason that you aren’t using Send-MailMessage – then you should switch. Next, if you’re trying to avoid the email being sent if the attachment isn’t present or do something else (such as send a message to support) then you could consider something like this.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.