I have been working on a daily check report for our VMware environment so that we don’t have to manually check each morning.
The report uses PowerCli to generate information and then output the results to a HTML file.
The report requires a few that either the old PowerCLI snapin is available or preferably the PowerCLi PowerShell module.
The script can either be run directly by a users with rights to query vCenter or by setting up a scheduled task.
The following prerequisite will be needed for the script to run.
- PowerShell V4 or V 5
- PowerCLI 6.0 or later version
- vCenter 6.0 or later version
There will also need to be a mail server or relay server available for the report to be emailed.
This has been tested on PowerCLI version 6.0 and above. The version on the server I will be running from is 12.3.0 which is the latest release at this time.
The report checks
- vCenter connection
- VMware tools check
- Snapshot older than the specified snapshots days
- Host Alarms
- VM Alarms
- vCenter Alerts over the last 12 hours
- Datastore under specified % free space
There are mandatory parameter that are required for the script to run and send the report.
- VCServer = vCenter Server address
- SMTPServer = Mail server address
- Toaddress = destination email
- Fromaddress = sending address
- Report Export = folder report will be exported to
There are some variables at the start of the script that can be set to customize the report to only show the required snapshots days and datastore % free. In my case I wanted 3 days and below 20% free on datastores.
I have embedded the html CSS format in the script so it can be update to change the color, font size or font type.
Example of how to run the script is below
.\VMwareDailReportv1.ps1 -VCServer vcenter.domain.local -SMTPServer mail.doamin.local -FromAddress VMwareReport@domain.local -toAddress Administrator@domain.local -ReportExport D:\Scripts\VMware\Daily_Report
Once completed the report should be emailed to the specified to address.
Below is an example of the report export.
The full script can be downloaded from.
To create a scheduled task to run the report each morning go to scheduled task on the server or client that has PowerCLI installed.
Create a new task
Set the schedule.
Next we need to set PowerShell as the program to start and set the argument to similar to the below, updating the parameters and script location
-ExecutionPolicy Bypass -NoProfile -File D:\Scripts\VMware\Daily_Report\VMwareDailReportv1.ps1 -VCServer vcenter.domain.local -SMTPServer mail.doamin.local -FromAddress VMwareReport@domain.local -toAddress Administrator@domain.local -ReportExport D:\Scripts\VMware\Daily_Report
I don’t change anything on conditions tab and only update that stop task if running longer than an hour in the settings tab.
Once completed run the task to confirm all is working.
I will probable added to the script but this is just the initial version and thought it might be helpful to anyone who want to try automate some of there manual checks.