Send-MailMessage拒绝访问路径

时间:2017-10-02 19:28:29

标签: powershell

我正在尝试使用powershell通过电子邮件发送文件。我可以弹出提示输入凭证的密码。但是send-mailmessage回来说道路被拒绝了。还有一种方法可以在脚本中包含密码以绕过输入密码,以便我可以通过服务器上的任务调度程序运行它吗?

Send-MailMessage -From 'David Brierton <Davidb@test.com>' -To 'David Brierton <Davidb@test.com>' -Subject "Website deployment" -Body "See attached file" -Attachments @("\\server\d$\Mdrive\test\test\Book1.csv", "\\server\d$\Mdrive\test\test\ExampleBook1.csv") -SmtpServer test.test.test -Credential DomainName\User

1 个答案:

答案 0 :(得分:0)

删除-attachement中的@和括号,只使用您的电子邮件

Send-MailMessage -From "Davidb@test.com" -To "Davidb@test.com" -Subject "Website deployment" -Body "See attached file" -Attachments "\\server\d$\Mdrive\test\test\Book1.csv", "\\server\d$\Mdrive\test\test\ExampleBook1.csv" -SmtpServer test.test.test -Credential DomainName\User