PowerCLI

 View Only
  • 1.  Daily reports from our clusters

    Posted Feb 28, 2026 10:58 PM
      |   view attached

    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. 



    -------------------------------------------

    Attachment(s)

    ps1
    VMwareDailyReport.ps1   10 KB 1 version


  • 2.  RE: Daily reports from our clusters

    Posted Mar 02, 2026 03:46 AM
    Edited by JStars Mar 02, 2026 09:45 AM

    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.

    -------------------------------------------