8000 Add Obsolete message to Send-MailMessage by TravisEz13 · Pull Request #9178 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Microsoft.PowerShell.Commands
/// <summary>
/// Implementation for the Send-MailMessage command.
/// </summary>
[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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,16 @@ Describe "Send-MailMessage" -Tags CI, RequireSudoOnUnix {

$server | Should -Not -Be $null

Send-MailMessage @InputObject -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. *"

$mail = Read-Mail

Expand Down
0