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
Requirements:
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
http://www.vmware.com/download/sdk/
Set the ExecutionPolicy in Windows Powershell to RemoteSigned by using the following command:
set-ExecutionPolicy RemoteSigned
Installation:
– 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
Configuration:
– Edit the Powershell.ps1 file
edit the following variables:
$vcserver=”localhost”
Enter the VC server, if you execute the script on the VC server you can use the localhost name
$filelocation=”D:\temp\Healthcheck.htm”
Specify the location where to store the HTML output
$enablemail=”yes”
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
Usage:
Manually run the Healthcheck.ps1 script”:
1. Open Powershell
2. Browse to the directory where the Healthcheck.ps1 script resides
3. enter the command:
./Healthcheck.ps1
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 .
Future:
– 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:
[ad#verticaal]
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%
Can you send me the updated script?
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….
Hi,
How to have the final html report i.e., $filelocation to be displayed as a body of the mail message.
Thx.
Is it possible to get vm health report in XML Format similar to HTML
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
thanks,
Vijay.
This is very helpful, I didn’t have any issues trying to implement this in our datacenter.
Thank you
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.
Thanks,
Hemant
Its very useful script, I have modified some fields according to my requirements… Thanks Ivo Beerens
Work for me! thanks
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
I’m still confuse for this configuration
1. where is the Powershell.ps1 file location?
2. where and How to put vcenter usernama and password ?
please send me the detail configuration to indra.tresna.setiadi@gmail.com
Instructions on how to protect usernames and passwords
http://vmwaremine.com/2013/04/19/schedule-task-with-powercli-script/
#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
please help me to find script healthcheck.ps1
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.
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