【发布时间】:2017-11-06 03:07:38
【问题描述】:
我正在尝试通过命令行执行以下命令
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Send-MailMessage -from "mail.me" -to "mail.me" -Subject "PS test !" -Body "Hi this is a power shell mail test" -SmtpServer "mail.domain.com"
但我收到以下错误:
Send-MailMessage : A positional parameter cannot be found that accepts arguement « test ».
Au niveau de ligne : 1 Caractère : 17
+ Send-MailMessage <<<< -from mail.me -to mail.me -Subject PS test ! -Body Hi this is a power shell mail test -SmtpServer mail.domain.com
+ CategoryInfo : InvalidArgument: (:) [Send-MailMessage], Paramet
erBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
.Commands.SendMailMessage
问题是同样的命令在 Power Shell 中直接执行时效果很好,但没有路径。
产生此异常的问题可能是什么?
【问题讨论】:
-
Send-MailMessage不是 PowerShell 版本 2 cmdlet? -
我确保它与 Power Shell 控制台指向的路径相同..
标签: powershell cmd parameters