Skip to content

HadErrors() returns $true if Send-MailMessage cmdlet is used #10015

Closed

Description

@kkbruce

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

Activity

  1. added
    Issue-Question
    on Jun 27, 2019
  2. changed the title [-]My bug report[/-] [+]HadErrors() returns $true if Send-MailMessage cmdlet is used[/+] on Jul 2, 2019
  3. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  4. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  5. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  6. added
    Resolution-No Activity
    on Nov 16, 2023
  7. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionResolution-No ActivityWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions