VMware Powershell Healthcheck script

Healthcheck is a Powershell script that reports information like snapshots, VMware tools version, datastore space, CDROM and/or floppy drives connected etc. to HTML and e-mail the output to a person or distribution list.

Reason for creating this script:

As VMware Consultant I see a lot of common problems in VMware environments like:

– Snapshots are enabled and forgot the commit to the VM.

– Datastores are almost full (for example if snapshots are enabled)

– VMware tools versions are different

– CDROM and floppy drives are still mounted to the VM

– Virtual Machines have CPU and Memory limits or reservations (VMs are swapping)

– In the VM, the VMware Tools timesync option is not enabled

In the Virtual Infrastructure Client (VIC) it is difficult to see this sort of information. By creating a Powershell script,  I can do a quick inventory.  In a lot of VMware environments I created a scheduled tasks, so the script runs once a week and sent to HTML rapport to the administrator.

What does the script:

I wrote a Powershell script with HELP from the VMTN community that makes a HTML file and sent the output by e-mail to a person or distribution list.  The Healthcheck script does the following checks:

– VMware ESX hardware

– VMware ESX versions

– VMware VirtualCenter versions

– Active snapshots

– CDROM and Floppy drive(s) mounted to the VM

– Datastore information like capacity, free space and the percentage free space

– VirtualMachine (VM) information like VMware tools version, CPU, Memory reservations and limits etc.

– On what VMs VMware Tools timesync is not enabled


The following software must be installed:

Microsoft Powershell 1.0 (http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx)

VMware Infrastucture (VI) toolkit for Windows 1.0


Set the ExecutionPolicy in Windows Powershell to RemoteSigned by using the following command:

set-ExecutionPolicy RemoteSigned


– Unzip the Healthcheck.zip script to a directory on the VC server for example.

– When the ZIP if unpacked there are two files:

– Healthcheck.ps1, this is the Powershell script

– Style.CSS, controls the HTML layout


– Edit the Powershell.ps1 file

edit the following variables:


Enter the VC server, if you execute the script on the VC server you can use the localhost name

Specify the location where to store the HTML output

Enable (yes) or disable (no) to sent the script by e-mail

$smtpServer = “mail.ivobeerens.nl”
Specify the SMTP server in your network

$mailfrom = “VMware Healtcheck <powershell@ivobeerens.nl>”
Specify the from field

$mailto = ivo@ivobeerens.nl

Specify the address where the e-mail to sent  to


Manually run the Healthcheck.ps1 script”:

1. Open Powershell

2. Browse to the directory where the Healthcheck.ps1 script resides

3. enter the command:


To create a schedule task in for example Windows 2003 use the following syntax in the run property:
Powershell -command “& ‘path\Healthcheck.ps1’
edit the path

Powershell -command “& ‘path\Healthcheck.ps1’

edit the path .


– List Orphaned VMDK’s

– Add performance information like VM usage

– Check timesync on the VMware hosts

Happy testing 🙂

Download Link: Healthcheck script

The script is posted on the VMware Powershell contest forum, link

Some screenshots of the HTML output:







41 thoughts on “VMware Powershell Healthcheck script”

  1. Thanks for your script

    Is it possible to add color in the html file for percfree. for example red color if percfree less than 10%

  2. Hey there, I haven’t checked the source of your powershell script out yet, but is this still compatible with vSphere? Are there any cmdlets run that could potentially modify the VC database? Or is everything in this just to retrieve info? Trying to figure out whether this would be safe to run against our vCenter environment now….

  3. Hi,

    How to have the final html report i.e., $filelocation to be displayed as a body of the mail message.


  4. I didnot get the response to the above question

    “Is it possible to get vm health report in XML Format similar to HTML”

    Please reply, it is urgent


  5. Hi, This is very useful script, Can anyone send me the update script with the ambedded CSS code as well on hemant_patel@symantec.com.

    I tried to change in existing script but didnt work for me in emailed report.


  6. Its very useful script, I have modified some fields according to my requirements… Thanks Ivo Beerens

  7. I have some issues when I run the script twice. The report on VM information adds on to the list which has some errors. Anyone has any errors similar?

    Is there an updated script for this? Appreciated it.

    Can send to me @ rockermocker84@gmail.com

  8. Instructions on how to protect usernames and passwords
    #To create the credential store files
    New-VICredentialStoreItem -Host ESX-or-vCenter-Hostname -User username -Password ‘password’ -File C:\path-where-to-store-file.xml

    #To use the data stored in the XML file, we will call the Get-VICredentialStoreItem
    $Credential = Get-VICredentialStoreItem -Host vcenterserver -File C:\path-where-to-store-file.xml

    #Use the $Credentials variable for the username and password switches in the Connect-VIServer
    Connect-VIServer vCenterserver-or-ESX-host -User $Credential.User -Password $Credential.Password

  9. hello team,

    I am getting below error while downloading the script. Please someone give me the access or send me the script and HTML file to baljits@quickplay.com

    We are sorry, but access to this place or content is restricted. If you believe this message to be in error, please contact the system administrator at community_mgr@vmware.com or the person who directed you here.

  10. I am getting below error while executing the script.

    Add-PSsnapin : No snap-ins have been registered for Windows PowerShell version 5.
    At C:\Users\bs176s\Documents\vmwarehealthcheckscript\Healthcheck\Healthcheck.ps1:59 char:1
    + Add-PSsnapin VMware.VimAutomation.Core
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (VMware.VimAutomation.Core:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

    Initialize-VIToolkitEnvironment.ps1 : The term ‘Initialize-VIToolkitEnvironment.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable
    program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Users\bs176s\Documents\vmwarehealthcheckscript\Healthcheck\Healthcheck.ps1:60 char:1
    + Initialize-VIToolkitEnvironment.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Initialize-VIToolkitEnvironment.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    And when script finished it throws this error.

    Exception calling “Send” with “1” argument(s): “Failure sending mail.”
    At C:\Users\bs176s\Documents\vmwarehealthcheckscript\Healthcheck\Healthcheck.ps1:198 char:1
    + $smtp.Send($msg)
    + ~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SmtpException

Leave a Comment