Skip to content

Send-MailMessage.Tests.ps1 - failure in 'Can send mail message from user to self using pipeline ' #7592

@dantraMSFT

Description

@dantraMSFT

NOTE: See also #7591

Steps to reproduce

Start-PSPester -Path ./test/powershell/Modules/Microsoft.PowerShell.Utility/Send-MailMessage.tests.ps1

Expected behavior

The tests pass.

Actual behavior

The tests fails with the error 'A null key is not allowed in a hash literal'

The cause of the failure is the SmtpServer part of the hash table that is piped to Send-MailMessage. Note the '$' before the SmtpServer hash key. This is resolving to an empty string.

$object = [PSCustomObject]@{"To" = $address; "From" = $address; "Subject" = $subject; "Body" = $body; $SmtpServer = '127.0.0.1'}

The fix is to remove the $ from $SmtpServer. Also, the quotes around the other keys are not needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility moduleWG-Quality-Testissues in a test or in test infrastructure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions