Istanbul/Turkey

Daily Vcenter Report with VCheck

vCheck is a PowerShell HTML framework script written by Alan Renouf. This script picks on the key known issues and potential issues scripted as plugins. Enabling or Disabling the plugins is possible. 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 in the virtual infrastructure version of this script, it will not show in the email, this ensures that you have only the information you need in front of you. In other words, this script will only tell you about problem areas with your infrastructure.

First make sure PowerCLI is configured on the computer that you will run this server. You can read the following post for PowerCLI configuration.

https://configland.com/index.php/3rdparty/252-configuring-powercli

 

Download vCheck from code.vmware.com or github. Download the zip file and extract the package.

https://code.vmware.com/samples/823/-vcheck-vsphere

https://github.com/alanrenouf/vCheck-vSphere

 

Before you run the script, I recommend you to run the PS command below. Because vcheck script will run more than a 100 commands during the first configuration and you would not want to hit R(run) key each time it asks. This command will bypass those checks and run vcheck.

Set-ExecutionPolicy -ExecutionPolicy Bypass

 

I downloaded vcheck from code.vmware.com and when I run it for the first time vcheck script did not ask me for the inital configuration. I guess github has a newer version and github package might ask you to complete the initail configuration as it is told in this video. You can watch the video  for initial configuration details.

https://player.vimeo.com/video/36411677?h=491fef5d14

 

If Vcheck does not ask you for the initail configuration you can trigger it manually running vcheck with -Config switch like below.

'.\vCheck.ps1' -Config

 

You can also enter configuration settings manually in the ps1 files like below.

Browse  C:\vCheck\Plugins\00 Initialize folder and edit 00 Connection Plugin for vCenter.ps1

Find the following lines and edit your vcenter address

# Start of Settings
# Please Specify the address (and optional port) of the vCenter server to connect to [servername(:port)]
$Server = "EnterYourVcenterDNS or IP Address"
# End of Settings

 

Also find the following lines and add username, password and protocol information like this

$VIConnection = Connect-VIServer -Server $VIServer -user "yourusername@vsphere.local" -Pass "YourPassword"

 

 

After the configuration is ready, you can run vcheck script to generate the report. Change the Working Directory to vCheck folder and run vcheck.ps1

cd c:\vCheck

.\vcheck.ps1

If you want to save the generated reports in a folder you can run the command like this:

.\vcheck.ps1 -OutputPath c:\vCheckOutput\DailyReports

 

You can add additional vCheck Plugins  or remove unwanted plugins from your report. The following short video by Jake Robinson explains it clearly.

 https://www.youtube.com/watch?v=S_xKCVXAq2E

http://geekafterfive.com/2012/02/08/vcheck6-utility-commands/

 

Email Settings:

You can also send the generated report in an email eachtime vcheck script runs.

Edit GlobalVariables.ps1 file and modify it according to your environment.

 

# Use the following item to define if an email report should be sent once completed
$SendEmail = $true
# Please Specify the SMTP server address (and optional port) [servername(:port)]
$SMTPSRV = "yoursmtpserver.mydomain.local"
# Would you like to use SSL to send email?
$EmailSSL = $false
# Please specify the email address who will send the vCheck report
$EmailFrom = "vcheck@mydomain.local"
# Please specify the email address(es) who will receive the vCheck report (separate multiple addresses with comma)
$EmailTo = "user1@mydomain.local, user2@mydomain.local,user3@mydomain.local"
# Please specify the email address(es) who will be CCd to receive the vCheck report (separate multiple addresses with comma)
$EmailCc = "manager@mydomain.local"
# Please specify an email subject
$EmailSubject = "$Server vCheck Report"
# Send the report by e-mail even if it is empty?
$EmailReportEvenIfEmpty = $true
# If you would prefer the HTML file as an attachment then enable the following:
$SendAttachment = $true

 

 

Running vCheck with Task Scheduler:

It was not easy for me to run vcheck script with windows task scheduler. Some files (related PowerCLI initiator) were changed or removed affter the PowerCLI version 6.5 and documented way of running Task Scheduler did not work. So I used a batch file to run vcheck with Windows Task Scheduler. 

 Start-vCheck.bat

cd "%~dp0"
start powershell -noexit -Command "cd 'C:\vCheck'"
start powerShell -NoExit -Command ".\vCheck.ps1"

 

I used a domain account who has local admin permissions on the server. The vcenter I am testing this is not AD integrated, so the domain user I am using does not exist on Vcenter and it does not any problems. 

 

 

 

Then I directly used this batch file in Task Scheduler like below. If leave "Start in (optional)" textbox empty, the report is NOT generated correctly. 

 

 

 

 

Plugins:

There are many plugins for vcheck. You can add or remove plugins from your report. To manage Plugins run vCheckUtils.ps1 script. When you are running it make sure you run the script like

dot space dot vCheckUtils.ps1 (. .\vCheckUtils.ps1). Then run Get-vcheckCommand to see available commands.

 

 Get-vCheckPlugin -installed command will list the plugins which are currently installed.

 

 

You can also add or remove plugins by running select-plugins.ps1 script

 

  • Hits: 568