$SmtpServer = "smtp.server"
$From = "myself@email"
$To = "friend@email"
$Subject = "Weekly Admin Points Backup"
$Body = @"
Hello....
"@
$attachment = "F:\AdminPoints.docx"
Send-MailMessage -To $To -From $From -Subject $Subject -Body $Body -Attachments $attachment -SmtpServer $SmtpServer
尝试使用附件执行简单的PowerShell脚本时收到此错误:
Send-MailMessage : The process cannot access the file '*<Filepath>*' because it is being used by another process.
At <*script>*.ps1:9 char:17
+ Send-MailMessage <<<< -To $To -From $From -Subject $Subject -Body $Body -Attachments $attachment -SmtpServer $SmtpServer
+ CategoryInfo : NotSpecified: (:) [Send-MailMessage], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.SendMailMessage
我可以做些什么来解决?