PowerShell 3 RC: New Send-MailMessage Parameter for Port Number!

Did you know that in previous versions of Windows PowerShell, there was no built-in way to specify a custom port to send an e-mail to a SMTP server? It’s true, Microsoft did not include that parameter until the release candidate (aka. release preview) version of PowerShell version 3.0. The release candidate of Windows Management Framework 3.0 was made available for download on May 31st, 2012. The cmdlet in question here is the Send-MailMessage cmdlet, and just today, I noticed a comment from someone at Microsoft, saying that the new -Port parameter was included in the PowerShell 3.0 RC.

Upon closer, personal inspection, it’s true. The -Port parameter has been included! Here is the original bug filed on Microsoft Connect by Shay Levy:


All we have to do to verify the availability of the parameter is issue the Get-Help Send-MailMessage command.


    Sends an e-mail message.

    Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String>]
    [[-SmtpServer] <String>] [-Attachments <String[]>] [-Bcc <String[]>]
    [-BodyAsHtml [<SwitchParameter>]] [-Cc <String[]>] [-Credential
    <PSCredential>] [-DeliveryNotificationOption
    <DeliveryNotificationOptions>] [-Encoding <Encoding>] [-Port <Int32>]
    [-Priority <MailPriority>] [-UseSsl [<SwitchParameter>]] -From <String>

    The Send-MailMessage cmdlet sends an e-mail message from within Windows