Skip to content

Send-MailMessage: Positional Parameter Error #1751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hojomic opened this issue Feb 8, 2019 · 3 comments
Closed

Send-MailMessage: Positional Parameter Error #1751

hojomic opened this issue Feb 8, 2019 · 3 comments

Comments

@hojomic
Copy link

hojomic commented Feb 8, 2019

Issue Type: Bug

Run the following script with appropriate values for sender, recipient and SMTP relay:

 $from		= "\<Sender\>"
 $recipient	= "\<Recipient\>"
 $smtpRelay	= "\<SMTP Relay\>"
 $subject		= "E-mail Encryption (SMTP): Test 1"
 $body		= "Testing FuseMail SMTP..."
 Send-MailMessage –From $from –To $recipient –Subject $subject –Body $body -SmtpServer $smtpRelay -Port 25

This generates the following error:

Send-MailMessage : A positional parameter cannot be found that accepts argument 'Testing FuseMail SMTP...'.
At C:\Users\<User>\<OneDrive>\Development\PowerShell\Scripts\Send-EmailUsingSmtpRelay.ps1:6 char:1
+ Send-MailMessage –From $from –To $recipient1 –Subject $subject  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Send-MailMessage], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SendMailMessage

Running the same script in the PowerShell console or PowerShell ISE works without issue.

Also note the unexpected characters '–' in the error message.

Extension version: 1.11.0
VS Code version: Code 1.31.0 (7c66f58312b48ed8ca4e387ebd9ffe9605332caa, 2019-02-05T22:35:56.624Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.86GB (7.43GB free)
Process Argv
Screen Reader no
VM 0%
@SydneyhSmith
Copy link
Collaborator

Thanks for reporting this @hobbsjm ! It would be really helpful in terms of diagnosing the issue if you could provide logs, instructions for how to do that are here

@rjmholt
Copy link
Contributor

rjmholt commented Feb 14, 2019

This looks like an encoding problem; your PowerShell session is trying to read CP-1252, but VSCode has written the file in UTF-8 without a BOM.

The simplest solution is to set "files.encoding": "utf8bom" in your VSCode settings (Ctrl+,).

The PowerShell extension can't see this or configure around it -- it's a configuration problem between the PowerShell session and VSCode, one that's fixed in PowerShell 6.

See #1744.

If you hit another issue here, please let us know below and we can look into it.

@rjmholt rjmholt closed this as completed Feb 14, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Feb 14, 2019

To be really sure the file is UTF-8 with BOM, you can save it with that encoding like here: microsoft/vscode#44005 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants