Sending E-mail With PowerShell

Been looking for something like this in a while to test newly setup or existing SMTP setups for simple server notification or business applications e.g. SharePoint, as it saves you having to install telnet or putty in order to send a quick test email to make sure its not getting blocked somewhere i.e. spam:

## Update ##
Just found out there’s an actual powershell Cmdlet for this: Send-MailMessage!

$msg = new-object Net.Mail.MailMessage

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure
$msg.From = ""
$msg.subject = "My Subject"
$msg.body = "This is the email Body."

#Sending email

Thanks to SharePoint and Others for the basics!


Coffee Break: Windows Server 2012 First Look

One of the key things I’m liking with Windows Server 2012, is the new Server Manager. The new version is alot more useful than that of Windows 2008 and Windows 2008 R2 in that it appears to work out of the box, where as the previous involved alot of “tweaking” to get WinRM working.

This has a huge impact on the use of Server 2012 Core Edition, which unless you love doing everything on the command line or in PowerShell is pretty annoying to even get started with. However, the new server manager allows you to add roles and features from your local workstation along with launching applicable role tools right from the UI.

I’ve always likes the idea of Windows Server Core, but the practicality of managing it has always been and issue along with role limitations, although this appears to have also been “fixed”.

So far so good…

ADFS 2.0 (and IIS 7+) and Google Chrome

This one annoyed me for longer than I wish to share…

If you are having problems using Windows Authentication on IIS (in particular with the ADFS 2.0 passive federation) where you can login fine with Internet Explorer but Google Chrome simply repeats asking for your login and password then this is for you!

IIS has a new feature called “Extended Protection” for Windows Authentication. The appears to have an affect on Chrome but not IE, therefore to disable it do the following:

  1. Logon to the system which is hosting your web site
  2. Launch IIS Manager and navigate to the Virtual Directory (make sure you change this for your Virtual Directory not just the root of the web application)
  3. Select the “Authentication” feature
  4. Select “Windows Authentication”
  5. On the right hand task pane you should now see “Advanced Settings…”, select this
  6. Change or make sure that “Extended Protection” is off
After you complete the above Chrome should now allow you to enter your login details just the once!
Note: You can also change the ADFS 2.0 login type by editing the web.config under the “ls” virtual directory to forms if you prefer.