Found a user on Spiceworks who was struggling getting vbScript to send an email using SMTP authentication. While very possible to do in vbScript (Paul Sadowski great blog I’ve used for years) this is definitely one of those things where the code just looks ugly and it can be a little confusing. Powershell’s Send-MailMessage cmdlet takes all of that away. Combine that with the RSAT tools for Active Directory and you can do some pretty cool things very easily. So read on to see how I solved this problem.
This particular function rose out of another script I wrote a little while back, the Restart Computers with Firm Confirmation. I wanted to make a particular piece of it available for others to use in their own scripts or at least something I can always refer to within my own.