diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs index 506715eb5b..6ff29f110d 100644 --- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs +++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/Send-MailMessage.cs @@ -14,6 +14,7 @@ namespace Microsoft.PowerShell.Commands /// /// Implementation for the Send-MailMessage command. /// + [Obsolete("This cmdlet does not guarantee secure connections to SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage at this time. See https://aka.ms/SendMailMessage for more information.")] [Cmdlet(VerbsCommunications.Send, "MailMessage", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135256")] public sealed class SendMailMessage : PSCmdlet { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Send-MailMessage.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Send-MailMessage.Tests.ps1 index 5d8756006c..798c13edc2 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Send-MailMessage.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Send-MailMessage.Tests.ps1 @@ -115,7 +115,16 @@ Describe "Basic Send-MailMessage tests" -Tags CI { } $user = [Environment]::UserName - $inPassword = Select-String "^${user}:" /etc/passwd -ErrorAction SilentlyContinue + $powershell = [PowerShell]::Create() + + $null = $powershell.AddCommand("Send-MailMessage").AddParameters($InputObject).AddParameter("ErrorAction","SilentlyContinue") + + $powershell.Invoke() + + $warnings = $powershell.Streams.Warning + + $warnings.count | Should -BeGreaterThan 0 + $warnings[0].ToString() | Should -BeLike "The command 'Send-MailMessage' is obsolete. *" if (-not $inPassword) { $PesterArgs["Pending"] = $true