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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | NAME Send-MailMessage SYNOPSIS Sends an e-mail message. SYNTAX 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> [<CommonParameters>] DESCRIPTION The Send-MailMessage cmdlet sends an e-mail message from within Windows PowerShell. |