please check your code to see if after the backtick there is a space. In PowerShell, the backtick (`) must be the very last character on the line. If there is any space after the backtick, it breaks the continuation and causes a parsing error. Or use splatting instead:
$params = @{
From = $FromAddress
To = $toaddress
Subject = "VMware Daily Report"
Body = "VMware Daily Report attached"
SmtpServer = $SMTPServer
Attachments = "$ReportExport\$VCServer-DailyReport.htm"
}
Send-MailMessage @params
if it keeps failing you will need to run the file manually without the scheduler to read any error.
-------------------------------------------
Original Message:
Sent: Feb 26, 2026 12:08 PM
From: Andrew Kaplan
Subject: Daily reports from our clusters
Hello.
We recently completed the upgrade of our two clusters to the 8.0.3 release. Now that is done, my next step is to set up daily reports to get the status of each cluster. My plan is to use PowerCLI to accomplish this task.
I have been experimenting with several different scripts, and they seem to work well when run interactively. Doing it the same thing through Task Scheduler has been problematic.
One script, VMwareDailyReports, will generate an output file and also email the file when manually run. However, when the script is set up to run as a scheduled task, the output file is generated, but the email is not sent. Also, the script will run on a Windows 11 Pro workstation, but runs into problems when run interactively or automatically on a Windows 2019 server. The script has been attached to this posting.
What I want to accomplish is to have the script run successfully in Task Scheduler on either the Windows 11, or ideally, on the Windows 2019 server.
-------------------------------------------