-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Steps to reproduce
I user PowerShell Class (version 6.2.1) in .NET Core project, If scripts include Send-MailMessage cmdlet, shell.HadErrors get true:
using (PowerShell shell = PowerShell.Create())
{
shell.AddScript(scripts);
var results = shell.Invoke();
if (shell.HadErrors)
{
_logger.LogTrace($"shell.HadErrors is {shell.HadErrors}");
}
}I trace shell.Streams object, only Warning count 1, other PSDataStreams properties (Error ...) count 0.
Warning message is new System.Collections.Generic.ICollectionDebugView<System.Management.Automation.WarningRecord>(shell.Streams.Warning._data).Items[0] {The command 'Send-MailMessage' is 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.} System.Management.Automation.WarningRecord
Expected behavior
shell.HadErrors is false.
Actual behavior
shell.HadErrors is true.
Environment data
Name Value
---- -----
PSVersion 5.1.17134.765
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.765
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1