Friday, August 6, 2010

Hey! A send email cmdlet!

So from the ‘oh my god I can’t believe I hadn’t found this earlier’ corner comes this:  PowerShell 2.0 ships with a new cmdlet called Send-MailMessage.  Why is this kinda sorta a big deal (at least to me, haha)?  PSCX will be deprecating the Send-SmtpMail cmdlet (that you may or may not have been using profusely, I know I have) in the next major revision.  So it’s time to start going through scripts and updating as needed.  Thankfully, the syntax is very similar.  The only changes that I found I needed to make were:

  • Change –AttachmentLiteralPath/-AttachmentPath to –Attachments
  • Change –SmtpHost to –SmtpServer