vCheck (Daily Report)

Introduction

vCheck is a vCenter checking script, the script is designed to run as a scheduled task before you get into the office to present you with key information via an email directly to your inbox in a nice easily readable format.

This script picks on the key known issues and potential issues of the virtual infrastructure and reports it all in one place so all you do in the morning is check your email.

One of they key things about this report is if there is no issue in a particular place you will not receive that section in the email, for example if there are no datastores with less than 5% free space (configurable) then the disk space section will not show in the email, this ensures that you have only the information you need in front of you when you get into the office.

This script is not to be confused with an Audit script, I don’t want to remind you that you have 5 hosts and what there names are and how many CPU’s they have each and every day as you don’t want to read that kind of information unless you need it, this script will only tell you about problem areas with your infrastructure.

What is checked for ?

The following items are checked for by default but these can be disabled individually to make the script run faster and remove unwanted items from the report, see “Configuring the script” below for details.

  • General Details
    • Number of Hosts
    • Number of VMs
    • Number of Templates
    • Number of Clusters
    • Number of Datastores
    • Number of Active VMs
    • Number of Inactive VMs
    • Number of DRS Migrations for the last days
  • Snapshots over x Days old
  • Datastores with less than x% free space
  • VMs created over the last x days
  • VMs removed over the last x days
  • VMs with No Tools
  • VMs with CD-Roms connected
  • VMs with Floppy Drives Connected
  • VMs with CPU ready over x%
  • VMs with over x amount of vCPUs
  • List of DRS Migrations
  • Hosts in Maintenance Mode
  • Hosts in disconnected state
  • NTP Server check for a given NTP Name
  • NTP Service check
  • vmkernel warning messages ov the last x days
  • VC Error Events over the last x days
  • VC Windows Event Log Errors for the last x days with VMware in the details
  • VC VMware Service details
  • VMs stored on datastores attached to only one host
  • VM active alerts
  • Cluster Active Alerts
  • If HA Cluster is set to use host datastore for swapfile, check the host has a swapfile location set
  • Host active Alerts
  • Dead SCSI Luns
  • VMs with over x amount of vCPUs
  • vSphere check: Slot Sizes
  • vSphere check: Outdated VM Hardware (Less than V7)
  • VMs in Inconsistent folders (the name of the folder is not the same as the name)
  • VMs with high CPU usage
  • Guest disk size check
  • Host over committing memory check
  • VM Swap and Ballooning
  • ESXi hosts without Lockdown enabled
  • ESXi hosts with unsupported mode enabled
  • General Capacity information based on CPU/MEM usage of the VMs
  • vSwitch free ports
  • Disk over commit check
  • Host configuration issues
  • VCB Garbage (left snapshots)
  • HA VM restarts and resets
  • Inaccessible VMs

Prerequisites

The following will need to be installed for you to run this script:

  • PowerShell V2
  • PowerCLU 4.0 U1 or later version
  • vCenter 2.5 or later version

Configuring the script

All configuration is stored at the top of the script, it is recommended you check the configuration and change the thresholds before running the script as this will help the script focus on your issues and best practices.

Changing the email information

Just after the comments you will find the following information:

# You can change the following defaults by altering the below settings: #
# Set  the SMTP Server address $SMTPSRV = "mysmtpserver.mydomain.local"
# Set the Email  address to recieve from
$EmailFrom = "me@mydomain.local"
# Set the Email address  to send the email to
$EmailTo = "me@mydomain.local"

This information will need to be adjusted to your specific requirements in order for the email to work.

If you wish to add multiple recipients then change the $EmailTo to the following:

$EmailTo = “user@domain.com,user2@domain.com"

Setting the thresholds

This will help the script focus on the specific areas you want to report on, it can be used to define your own best practices.

Just after the comments will be a “Detail Settings” part of the script, under here will be a variable for each setting, these are described by a comment before and will need to be changed to fit in with your own specific requirements.

An example is setting the ntp server, to do this change the current setting to match your configuration:

Before

# The NTP server to check
$ntpserver = "pool.ntp.org"

After

# The NTP server to check
$ntpserver = "ntp.mycompany.mydomainname.internal"

Running the script

The script is currently in “html view mode”, this means that after you have run the script it will display a HTML report with any errors which may be relevent, it is useful to run it in this mode until you are happy with the results, you can then change it to  “Email mode”.

To do this, find the area just after you have set the email settings and change the following variables to the required output:

$DisplaytoScreen = $true

$SendEmail = $false

To run the script from the PowerCLI prompt simply cd into the folder where the script is located and type the script name followed by your vCenter name as below:

.\vCheck5.ps1 vCenter01

Example:

image

Customising the report colours

Near the top of the report, just after the version comments will be two areas where you can define custom colours, use these to set the colours of the headings as below:

Main Title bar

$Colour1 = "CC0000"

image

Check bar

$Colour2 = "7BA7C7"

image

Adjusting connection information

In some cases you will need to adjust the connection information used by the connect-viserver cmdlet to connect to your vCenter, this can be adjusted on line 701 as below:

Before

$VIServer = Connect-VIServer $VISRV

After

$VIServer = Connect-VIServer $VISRV –user “AlternateUsername” –Pass “Alternatepassword” –Protocol Https

Example report

An example report can be seen by clicking the below image or here, please note that not all checks are triggered here.

image

Download

You can download the latest version of the script here.

  • #1 written by Virtu-Al
    about 2 months ago

    Sounds great, can you email them to me so I can see what you have done, I have a few good ideas for this myself but would be interested in what you have done.

  • #2 written by Reg
    about 2 months ago

    Is it possbile to have the html report only capture issue or misconfigurations? As more functionality is added to the script I can see myself scrolling through the full report looking for warning or issues only.

  • #3 written by Steve
    about 2 months ago

    Are you pointing this at your vCenter server or a host? I’m having trouble, I get an error:
    The Connect-VISERVER Cmdlet did not work, please check you VI Server.

    We’re running vSphere 4. Does it need to be run on the vCenter server itself?

  • #4 written by Steve
    about 2 months ago

    Oh wait, no panic. As we’re working with MSSCCM at the moment, I’d forgotten to reinstall a necessary component on my PC (using it for testing so was rebuilt).
    Thanks!

  • #5 written by Mark
    about 2 months ago

    Did you get my email with the modifies script?

  • #6 written by Tim
    about 2 months ago

    Hey Al,

    Would it be possible to include the option to exclude snapshots with a certain name? i.e replica_*

    We use your report on View environments and the report is constantly reporting the View snapshots.

    Thanks.

  • #7 written by Matt
    about 2 months ago

    Has anyone figured out a way to make this render properly in Outlook 2007/2010? I’m using the latest version of the script and I see the comment where you can modify the COLOR: to black so that it displays properly. I confirmed mine is set that way and I still cannot view this in Outlook.

    It looks great as HTML. Someone else had the suggestion of providing an option to just attach it as an HTML file. Is that possible?

  • #8 written by Matt
    about 2 months ago


    Matt:

    Has anyone figured out a way to make this render properly in Outlook 2007/2010? I’m using the latest version of the script and I see the comment where you can modify the COLOR: to black so that it displays properly. I confirmed mine is set that way and I still cannot view this in Outlook.
    It looks great as HTML. Someone else had the suggestion of providing an option to just attach it as an HTML file. Is that possible?

    Or you can actually modify the correct part of the script to make it work. I can confirm that the workaround does in fact work.. Sorry about that.

  • #9 written by Brian
    about 2 months ago

    Matt, I am having the same issue in Outlook. What did you modify to make it viewable in Outlook? Thanks

  • #10 written by Brian
    about 2 months ago

    I read other posts here and by changing the font color under .dsp from FFFFFF (White) to 000000 (Black) the text now shows up great in Outlook.

  • #11 written by Robert van den Nieuwendijk
    about 2 months ago

    In PowerShell V2 the ConvertTo-Html cmdlet has a -Fragment parameter that “Generates only an HTML table. The HTML, HEAD, TITLE, and BODY tags are omitted.”. I don’t know if this parameter is present in PowerShell V1. With the -Fragment parameter you can rewrite the Get-HTMLTable function into:
    Function Get-HTMLTable {
    param([array]$Content)
    $HTMLTable = $Content | ConvertTo-Html -Fragment
    Return $HTMLTable
    }

  • #12 written by Kris
    about 2 months ago

    I tried running the script, but it’s been at “…Checking capacity info” for more than 40 minutes now. Is this normal?

    Thanks,
    Kris

  • #13 written by Reg
    about 1 month ago

    Is there a way to have the html report added as a ‘tab’ within VCenter?

  • #14 written by Virtu-Al
    about 1 month ago

    You read my mind ;) yes there is, you can actually use my plugin generator script to add this and just amend the code so it creates the same html page each time.

  • #15 written by michael
    about 1 month ago

    love this script. been using it for some time but noticed it hangs on ” ..Checking Snapshots” section, even if left for hours. it there any way to tell what it might be hung up on?

    thanks.

  • #16 written by Virtu-Al
    about 1 month ago

    There is a problem with the get-snapshot cmdlet in the current release, look out soon on the vmware site for a new version of PowerCLI ;)

  • #17 written by tien lam nguyen
    about 1 month ago

    Hi, There

    your script is great. I have been using it for the last week.

    I would like to make a suggestion. Under the snapshots section I would be nice if we could get the amount in MB of the autual size of the snapshots.

    Right now we only get the total amount of disk size

  • #18 written by vincent
    about 1 month ago

    I am having some issues.

    What happens is that i am not able to get the script running.

    It says “connection to VI server” for a few seconds and then comes back to the command prompt. I do not find any HTML report.

    I have set all things correctly as i know. These are :

    1. Setting done to make the report display on screen.
    2. Setting done to enter my username in the script that would be used to connect to the virtualcenter server.

    Please help.

    Best Regards

    Vincent S

  • #19 written by vincent
    about 1 month ago

    I am trying this on another virtualcenter server and i get a message saying “the script is not digitally signed and so it will not run”.
    Please help.

  • #20 written by Chris
    about 1 month ago

    Is v5 only for vSphere? I have been using v3 with VI 3.5 with no problem but with v5, I am getting math errors. I am using ps2 and the latest PowerCLI.

    Attempted to divide by zero.
    At :line:571 char:73
    + $MyDetails.PercFreeSpace = [math]::Round(((100 * ($ds.FreeSpaceMB)) / <<<< ($ds.CapacityMB)),0)

  • #21 written by RobVM
    about 1 month ago


    Brian:

    I read other posts here and by changing the font color under .dsp from FFFFFF (White) to 000000 (Black) the text now shows up great in Outlook.

    Yes, the display of this report in Outlook 2007 is a pain. The table borders all show up with no content. Would it be possible to add the font color as a variable, and perhaps use that -fragment function for the HTML output? Otherwise this script works fantastic for us…thanks Al!

  • #22 written by RobVM
    about 1 month ago

    One more item. Would it be possible to check to see if the host is reporting hardware sensor info? There have been a few times where for whatever reason, the host doesn’t report this, and it does not raise an alert in vCenter. Then you try to run VUM and it won’t work properly because it can’t detect the power state of one of your hosts. This would be a big help!

  • #23 written by kevin
    about 1 month ago

    to shoh is tools need to be updated.
    Add this to turn on in the correct section
    $Showtoolsupdate = true

    Then add

    # —- VM Tools update —-
    If ($Showtoolsupdate){
    Write-CustomOut “..Checking VM Tools Out of Date”
    $UpdateTools = @($FullVM |Where {$_.Guest.ToolsStatus -eq “ToolsOld”} |Select Name, @{N=”Status”;E={$_.Guest.ToolsStatus}})
    If (($UpdateTools | Measure-Object).count -gt 0) {
    $MyReport += Get-CustomHeader “VM Tools Updates : $($UpdateTools.count)” “The following VMs have issues with VMtools and need to be updated”
    $MyReport += Get-HTMLTable $UpdateTools
    $MyReport += Get-CustomHeaderClose
    }
    }

  • #24 written by kevin
    about 1 month ago

    To show if tools need to be updated.
    Add this to turn on in the correct section
    $Showtoolsupdate = true

    Then add

    # —- VM Tools update —-
    If ($Showtoolsupdate){
    Write-CustomOut “..Checking VM Tools Out of Date”
    $UpdateTools = @($FullVM |Where {$_.Guest.ToolsStatus -eq “ToolsOld”} |Select Name, @{N=”Status”;E={$_.Guest.ToolsStatus}})
    If (($UpdateTools | Measure-Object).count -gt 0) {
    $MyReport += Get-CustomHeader “VM Tools Updates : $($UpdateTools.count)” “The following VMs have issues with VMtools and need to be updated”
    $MyReport += Get-HTMLTable $UpdateTools
    $MyReport += Get-CustomHeaderClose
    }
    }

  • #25 written by Traveller
    about 1 month ago

    Kevin,

    Should the $Showtoolsupdate = true be $Showtoolsupdate = $true

  • #26 written by Mike
    about 1 month ago

    Hi!
    thanks for this great report. i’m using it since version 3.
    now i have updated it to v5 but still now i have issues with it.

    it seems that the report is only generating only cluster in vcenter (only 5 from 70 hosts) so the report not finished.

    on excecuting there are no errors within runtime of the script.

    do you have some ideas?

  • #27 written by Traveller
    about 1 month ago

    Whilst updating our servers to v4.1 I had a thought :)

    It would be nice if the vCheck script could indicate which version the Hosts are running. Maybe have something that would show the highest version used in the cluster and which machines are not at that revision.

    That way you would not have to keep updating the script with which version you want to check for. Maybe that should be an option as well for those who want tighter control.

  • #28 written by Mike
    about 1 month ago

    I recently started testing this version, having used version 1.2 for a while now.
    Amazing work, however this one seems to take about 5 hours on the capacity info check, and then had some memory failure issues when checking snapshots.
    Have you seen this before?

  • #29 written by michael
    about 1 month ago

    does the script re-prompt for credentials on the vCenter services and event log sections for anyone else? i even tried to hard code in the -user and – password fields to no avail.

  • #30 written by Kris
    about 1 month ago

    can someone suggest me how can i run this script using task schedular? this script requires user Intervention to provide user account details.

    can we use stored creds in .xml file and run the sript in schedules?

  • #31 written by Kumar
    about 1 month ago

    We can able to see Letters in black in Outlook but background is Missing…. If background cloour also come.. it will look gr8.

    Any suggestions pls.


    Brian:

    I read other posts here and by changing the font color under .dsp from FFFFFF (White) to 000000 (Black) the text now shows up great in Outlook.

  • #32 written by Kumar
    about 1 month ago

    All,
    I run this script for ESX server.. it is showing Host minimal info and VM /DB info.. but am looking for a report which include below info of ESX server. Can some one please see below and help me if any script available.

    1. ESX Partiton info
    2. Root password age notification
    3. Esx current patch level / updates
    4. VMKernal errors
    5. ESX uptime
    6. ESX Hardware issues
    7. Security Warnings

    iF We can able to get the above info, easily we can able to administer ESX server. That report should have only issues not the information like vCheck5.ps1

    PLEASE HELP ME IS ANY ONE HAS LIKE THAT

  • #33 written by Kumar
    about 1 month ago

    Statement correction:

    iF We can able to get the above info, easily we can able to administer ESX server. That report should have only issues not the information like vCheck5.ps1
    ###########################################################
    iF We can able to get the above info, easily we can able to administer ESX server. That report should have only issues like vCheck5.ps1 not the information of ESX like other Daily health check scripts…

  • #34 written by Marty
    about 4 weeks ago

    Great script. I would like to make a suggestion for a future enhancement. Can you split the HTML and SmtpMail functions into their own module or ps1 file so that it can be imported into a session and used by other scripts. I have used your functions to build other HTML reports and would like to keep up with any enhancements to it in the furture without having to dowonload the script and remove the rest of the script.

  • #35 written by Bernt
    about 4 weeks ago

    Hi,
    Your script is amazing and very useful :-)

    In my environment we have a lot of lab VM’s with many snapshots.
    I would like to exclude them from the snapshot report.

    Is it possible to exclude a list of VM’s not to report on, similar to the $LVMDoNotInclude = “Template_*|VDI*” variable?

  • #36 written by Derek
    about 3 weeks ago

    Yes, please correct the base script so the HTLM renders properly in Outlook 2007/2010. Also, can you test against 4.1? Looks great!

  • #37 written by Bolsen
    about 3 weeks ago

    Here’s what I had to do to get v5 to work as a scheduled task with Windows 2008 R2.

    Problem – The script would not run as a scheduled task. It would run from the command line.

    Solution – Manually run the script from command line so it creates the .CRD file. Then modify $CredFile so it has the full path to the .crd file.

  • #38 written by Bolsen
    about 3 weeks ago

    Feature request:

    - Add “Top 10″ VMs with highest read IOPS and write IOPS
    - Add “Top 10″ VMs with highest read latency and write latency
    - In the prediction report – have the report include average VM disk size in the calculations.
    - Add a section for Host hardware status alerts

  • #39 written by Derrick
    about 2 weeks ago

    Al,

    Thanks for a great script. I have to admit though that I have not used it in its native form, but have shamelessly plagerised the pieces I need for my scripts. I have taken a slightly different tack (read diametrically opposite) to you with your health check script. I have created a single folder with a number of small scripts that do various pieces: some report on disk space to the SAN administrator, some report machine creation to the Infrastructure Manager and one of them even trawls logs, events and VM properties for information to include in custom fields in vCenter. This folder in itself simply becomes the scheduled task by running powershell across the folder using the following command : “Get-ChildItem *.ps1 | Invoke-Expression”. Works for me anyway and Thanks.

    Derrick

  • #40 written by Burak
    about 2 weeks ago


    tien lam nguyen:

    I would like to make a suggestion. Under the snapshots section I would be nice if we could get the amount in MB of the autual size of the snapshots.
    Right now we only get the total amount of disk size

    It would be great if we could see the actual snapshot size other than whole disk size. Is this a feature?

  • #41 written by Matt O
    about 2 weeks ago

    Anyone have any issues with how the report shows in outlook? I can’t see the description of each report. The box is blank. It shows fine when I run the script and it just saves the htm file.

  • #42 written by Bolsen
    about 2 weeks ago

    The problem with Outlook are well documented in the past 40 posts.

    The easy way to make it work in Outlook, is click the link at the top of the page that says “View in Browser”.

    But that brings up another feature request:

    - add the ability to save the report to a directory.
    - attach the report as an html file to email.

    It would be really nice if the reports could be stored on a network share, then the script sends an email saying when the report is ready.

  • #43 written by Mark
    about 2 weeks ago

    At the end of the script there already is code to save the file to a location. You just have uncomment the lines similar to this:
    __________________________________________________________________
    #Uncomment the following lines to save the htm file in a central location
    if ($DisplayToScreen) {
    Write-CustomOut “..Displaying HTML results”
    if (-not (test-path c:\tmp\)){
    MD c:\tmp | Out-Null
    }
    $Filename = “C:\Reports\” + $VIServer + “_DailyReport” + “_” + (Get-Date -format yyyy-MM-dd) + “.htm”
    $MyReport | out-file -encoding ASCII -filepath $Filename
    Invoke-Item $Filename
    }

    if ($SendEmail) {
    Write-CustomOut “..Sending Email”
    send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV $MyReport
    ____________________________________________________________________

    I send the output to file in the Reports folder & e-mail daily so I can review it at a later date if needed without keeping the e-mails.

    Hope this helps…
    Mark

  • #44 written by Results set is empty (mostly)
    about 1 week ago

    Hello I am running this from the VC locally and it runs through fine (takes about 15 minutes) but the html output consistently shows that it found only 1 host, 1 datastore, 1 VM, etc. I am not sure where else to look…it is running under my user context. The box is a 2008 box and I have tried to run it under the CLI in administrator mode and regular mode. I have the scripts folder on the F: drive so I am just entering the full path to the script with a space and the VC name at the CLI command prompt. Anything come into mind that I might be doing wrong?

  • #45 written by Robert Walker
    about 2 days ago

    Very nice script. I can see how this will be very useful to us in the future. What are you using to determine the capacity recommendations?