vCheck (Daily Report) V3
Initially when I started this script I wanted people to be clear that this was a report that was going to give you a daily summary of any issues which may exist in your Virtual Infrastructure, from the beta testing I did to a select few it was clear that they were expecting this to send them a full inventory of their infrastructure.
That wasn’t the point in this script and I think people now have the idea that this is more of an issue log than an audit script so I will now revert to my original name of…. vCheck.
The key thing to remember is that if an issue does not exist in a particular area then it will not show in the output, when and if issues turn up they will start appearing in the output almost like magic !
I want to thank everyone who is using this script and those who have left a comment, even if its just to say how much you like it !
I especially want to thank Raphaël SCHITZ (http://www.hypervisor.fr/) for all his contributions, he has added some great features to this version and helped me take it to a new level.
The previous version already reported on these areas:
- 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 stored on local datastores
- 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
So what is added to V3 ?
Well firstly I have fixed some bugs which existed in V2 and made things slightly faster.
The other added features are as below:
- Status report to screen whilst running interactively
- At the top of the script you can now turn off any areas you do not want to report on (this makes it faster to run)
- VMs on Local storage has been changed to report 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)
- Added the number of issues to each title line
As always please let me know if you have any comments, I already have some great ideas that I could not fit into this version so watch out for V4 !
Also a reminder that this script also checks your Windows vCenter server for services and event logs, it does this via WMI and therefore needs the correct permissions, there is still an area at the top of the script which you can give alternate credentials from the account that is running the script if needed.
If your new to this script and would like more details on how it looks or how to run it please check this post.







about 4 months ago
Awesome as usual.
about 4 months ago
Great job.
about 4 months ago
Juicy… Love the new script. Can’t wait for v4.
about 4 months ago
Change the name?? Daily Issue Checking?? LOL
Just every time you blog about vCheck be clear that it’s for issue checking??
about 4 months ago
hi Al , loving the script but it seems to be gettin upset calculating the cpu %ready stuff.
Note the script had been running for about 20 minutes at this point , is is posisble its hitting a timeout.
15:24 ..Checking VM CPU %RDY
Get-Stat : 04/11/2009 15:24:26 Get-Stat 1FE8AA92-9E03-450D-B247-A95E26B77
E89 The session is not authenticated.
At C:\temp\vcheckv3.ps1:827 char:54
+ $myObj.PercReady = [Math]::Round((($v | Get-Stat <<<< -S
tat Cpu.Ready.Summation -RealTime | Where {$_.Instance -eq $cpunum} | Measure-O
bject -Property Value -Average).Average)/200,1)
about 4 months ago
@Chris
Does it crash out or keep running ? Strange This was in the previosu version also, did you have any issues with the previous version ?
about 4 months ago
It does keep running. I seem to remeber having a few little bugs with the previous version – nb its running on a medium sized environment ( 21 hosts / 300 Vm’s ) – not braved it on the big one yet
about 4 months ago
might want to add an example report! Would be nice to see what it can do…
about 4 months ago
Duncan I’d forward one I did earlier but I’m embrassed as to the number of things its highlighted I need to get sorted out
about 4 months ago
@Duncan
Will do, just wanted to get the code out as I have been delaying it for a number of days so far, it will take a while to put one together that has all these issues for people to see what each one looks like
about 4 months ago
oh mines got lots of issues
about 4 months ago
Outstanding report, Al! We’ve been using it in our environment and has allowed us to be more proactive in fixing items before they become huge problems. By the way, Scott Herold was just at our Portland, OR VMWare Technical Conference and he gave you some love in his presentation on TheVesi. Thanks again for the script!
about 4 months ago
Excellent Report once again …..I was thinking about maybe if you could add a section that states the size of your vmkwarnings and or vmkernel log which would kind of lead to you looking at that host as something must be wrong if that file is any type of size in terms of having data written to it correct?
none the less Thank you once again for this fabulous reporting tool
about 4 months ago
“vmkernel warning messages ov the last x days” I see this listed but not on many my reports although I have two servers that have vmkwarning logs that get about 1-2gb every few days with scsi errors and such can you explain as I am missing something not enough fuel (coffee) yet this afternoon lol
about 4 months ago
Alan
Wow yet again, just when i thought v2 was the king script, along comes v3 with all sorts of new goodies.
Thanks for putting up a donation page, i felt compelled to give something back for all your hard efforts
Cheers
Paolo aka DJLO
about 4 months ago
Works like a charm. Nice Job!
about 4 months ago
Alan – WOW Again !! You continue to amaze me .. Within a week from release of the consolidated POWERPACK of yours.
Thanks again !!
Virtually anything is possible with you guys arnd !!
about 4 months ago
Super Script! Helps us a lot to keep track of the Virtual Environment.
Only one thing, when run against a vCenter4/esx4i environment I get this error for every Cluster it finds:
Method invocation failed because [VMware.Vim.ClusterComputeResource] doesn’t contain a method named ‘RetrieveDasAdvancedRuntimeInfo’.
At D:\scripts\DailyReport\DailyReport.ps1:701 char:61
+ $SlotDetails = $Cluster.RetrieveDasAdvancedRuntimeInfo( <<<< )
Any suggestions?
about 4 months ago
Hi,
please can someone tell me how to run this script?
My Batfile looks like:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Programme\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″&”C:\test\vCheckV3.psc1 vcenter”
I changed my mailserver and other parameters, but i don´t reviece a email yet.
Idea?
Big thanks
about 4 months ago
@Jerry C
Now thats the kind of comments I like, I love the fact that this script is showing people issues they never had or never even thought of looking for. Thanks for the comment.
about 4 months ago
@ZOMAN
At the moment I only pull the lines out which have the word ‘WARNING’ in it, is there other string matches you think may be usefull ?
about 4 months ago
@DJLO
Thanks man, that is so much appreciated. Thanks very much.
about 4 months ago
@Sudharsan
Thanks, I worked hard last week and this week to get them out.
about 4 months ago
@Harold
Do your clusters have HA enabled ?
about 4 months ago
@Switchgott
Mine looks like this:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ ” & “C:\Scripts\VMware\DailyReport.ps1 MYVISERVER”
I paste it into a dos window to make sure it works before adding to a scheduled task.
about 4 months ago
Great script, just saved me from a nasty situation that was prone to happen.
While i’m here, I would like to submit a feature request.
1) The posibility to only include some (one or more) clusters within the VI configuration and thus exclude all others. We have multiple clusters of which other departments are in control of. I don’t want to know there problems and they don’t want to know mine.
2) In the Snapshot inventory (date > snapshop creation date) can you add a column that specifies on what cluster the guest is running?
about 4 months ago
Thanks for your answer!If i post in dos box, looks loke this:
C:\WINDOWS>C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleF
ile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1? ” & “C:\S
cripts\VMware\DailyReport.ps1 MYVISERVER”
This comments are the problem: ″ ” & “C
about 4 months ago
@Switchgott
Ok, so you got it working ??
about 4 months ago
@Vincent
Its a good idea, I was thinking about adding a switch to the script for datacenter and cluster only reports
about 4 months ago
I’m having problems, connecting to the VI Server, it gives me a certificate warning and I can’t connect.
Does anyone have an idea, on how to fix this?
PS C:\install\VSphere Addons> .\Status.ps1 itgvc001
11:15 Connecting to VI Server
There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated in a root certificat
e which isn’t trusted by the trust provider.
* The certificate’s CN name does not match the passed value.
Connect-VIServer : not connected
At C:\install\VSphere Addons\Status.ps1:483 char:29
+ $VIServer = Connect-VIServer <<<< $VISRV
Connect-VIServer : not connected
At C:\install\VSphere Addons\Status.ps1:494 char:30
+ $VIServer = Connect-VIServer <<<< $VISRV
about 4 months ago
@Thomas Paulsen
Updated Powershell to v2, now I have a more detailed error message:
PS C:\install\VSphere Addons> .\Status.ps1 itgvc001
11:33 Connecting to VI Server
There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated in a root certificat
e which isn’t trusted by the trust provider.
* The certificate’s CN name does not match the passed value.
Connect-VIServer : not connected
At C:\install\VSphere Addons\Status.ps1:483 char:29
+ $VIServer = Connect-VIServer <<<< $VISRV
+ CategoryInfo : NotSpecified: (:) [Connect-VIServer], ViServerCo
nnectionException
+ FullyQualifiedErrorId : VMware.VimAutomation.Types.ViServerConnectionExc
eption,VMware.VimAutomation.Commands.ConnectVIServer
Connect-VIServer : not connected
At C:\install\VSphere Addons\Status.ps1:494 char:30
+ $VIServer = Connect-VIServer <<<< $VISRV
+ CategoryInfo : NotSpecified: (:) [Connect-VIServer], ViServerCo
nnectionException
+ FullyQualifiedErrorId : VMware.VimAutomation.Types.ViServerConnectionExc
eption,VMware.VimAutomation.Commands.ConnectVIServer
about 4 months ago
Thanks for the quick response.
This was my mistake,…. launched the script from VI toolkit 1.5.
RetrieveDasAdvancedRuntimeInfo is a vSphere PowerCLI 4.0 method.
I have upgraded and now it runs fine!
about 4 months ago
@Thomas Paulsen
Problem has been solved by installing VI Toolkit 1.5
But the CN Name certificate problem still exists, although it does not prevent the script from doing it’s job.
More detail on the “error” warning, now with VI Toolkit 1.5:
WARNING: There were one or more problems with the server certificate:
* The X509 chain could not be built up to the root certificate.
* The certificate’s CN name does not match the passed value.
about 4 months ago
Hi, no, not realy!
about 4 months ago
@Harold
Glad you managed to resolve it.
about 4 months ago
@Switchgott
I take it the script runs if you run it manually from PS or from an editor ?
about 4 months ago
@Thomas Paulsen
Glad you managed to resolve it, dont worry about the warning to do with the certificate, just so long as it doesnt stop the script from working.
about 4 months ago
There are couple of Requests too
1)Is it possible to report the Average utilization of the vSphere Server say for a specific period of time so that we also will know how over / under utilized is the vSphere Server ?
2 ) Also , is there a way to run this for multiple Virtual Center Servers in the same schedule and generate a single report ?
about 4 months ago
Alan, I have a feature request
Can you add a cluster memory section:
- How much Memory is available in the cluster?
- Huw much Memory is granted to VMs in this cluster?
Why? I need to know when I take one host in maintenance, can the rest of the hosts in the cluster handle these vm’s, without memory overcommitment.
(We have a N+1 hosts policy, no memory overcommitment)
Thanks,
Harold
about 4 months ago
Alan, thanks for the great script. We are using it daily to check our 125 ESX 3.5 hosts. The only issue I have seen so far is that it takes a long time to process the VMs with CPU ready over x% part. Never seems to finish.
I too was also interested in a cluster memory section that would report memory usage in the event of host failures.
Is was working on adding this to the script.
# —- Cluster Capacity —-
$MyReport += Get-CustomHeader “1″ “Cluster Utilization”
$ClusterInfo = @()
$clusters = Get-Cluster | Sort Name
ForEach ($cluster in $clusters)
{
Write-Output $cluster
$ClusterCapacity = “” | Select-Object “ClusterName”, “TotalHosts”, “TotalMemGB”, “UsedMemGB”, “PercMemUsed”, “PercMemUsed1Fail”, “PercMemUsed2Fail”
$esxhosts = Get-VMHost -Location $cluster
ForEach ($VMhostView in ($esxhosts | Get-View))
{
$TotalMemorySize += $vmhostView.Hardware.MemorySize
$TotalMemoryUsed += $vmhostView.Summary.QuickStats.OverallMemoryUsage
}
$NumHostsInCluster = ($esxhosts | Measure-Object).Count
$TotalMemorySizeGB = [math]::Round($TotalMemorySize/1GB,$digits)
$TotalMemoryUsedGB = [math]::Round($TotalMemoryUsed/1024,$digits)
$TotalMemorySizeGB1Host = [math]::Round($TotalMemorySizeGB / $NumHostsInCluster)
$TotalMemorySizeGB1Failure = [math]::Round(($NumHostsInCluster-1)*$TotalMemorySizeGB1Host)
$TotalMemorySizeGB2Failure = [math]::Round(($NumHostsInCluster-2)*$TotalMemorySizeGB1Host)
$PercentMemoryUsed = [math]::Round(($TotalMemoryUsedGB / $TotalMemorySizeGB) * 100, 0)
$PercentMemoryUsed1Failure = [math]::Round(($TotalMemoryUsedGB / $TotalMemorySizeGB1Failure) * 100, 0)
$PercentMemoryUsed2Failure = [math]::Round(($TotalMemoryUsedGB / $TotalMemorySizeGB2Failure) * 100, 0)
if ($NumHostsInCluster -lt 8){$PercentMemoryUsed2Failure = “n/a”}
$ClusterCapacity.ClusterName = $cluster
$ClusterCapacity.TotalHosts = $NumHostsInCluster
$ClusterCapacity.TotalMemGB = $TotalMemorySizeGB
$ClusterCapacity.UsedMemGB = $TotalMemoryUsedGB
$ClusterCapacity.PercMemUsed = $PercentMemoryUsed
$ClusterCapacity.PercMemUsed1Fail = $PercentMemoryUsed1Failure
$ClusterCapacity.PercMemUsed2Fail = $PercentMemoryUsed2Failure
$ClusterInfo+=$ClusterCapacity
$TotalMemorySize = 0
$TotalMemoryUsed = 0
$NumHostsInCluster = 0
$TotalMemorySizeGB = 0
$TotalMemoryUsedGB = 0
$TotalMemorySizeGB1Host = 0
$TotalMemorySizeGB1Failure = 0
$TotalMemorySizeGB2Failure = 0
$PercentMemoryUsed = 0
$PercentMemoryUsed1Failure = 0
$PercentMemoryUsed2Failure = 0
}
$MyReport += Get-HTMLTable $ClusterInfo
$MyReport += Get-CustomHeaderClose
This code probably needs more work, but I am still learning.
I was looking to have a separate report that would be used for Capacity Planning with sections on the report that would have Cluster Utilization based on Memory, CPU, Storage and VM info.
Once againg thanks for your great work!
about 4 months ago
Hi Alan,
Great work on the vCheck script! I added some extra functionality that checks probems that I encountered on my company’s VMware environment:
# —- check for vms with unknown status —-
If ($ShowUnknownVMstatus){
Write-CustomOut “..Checking for VMs with unknown status”
$vmstatus = @($FullVM | Select Name, @{N=”OverallStatus”;E={$_.overallstatus}} | where {$_.OverallStatus -eq ‘gray’})
If (($vmstatus | Measure-Object).count -gt 0) {
$MyReport += Get-CustomHeader “1″ “VMs with unknown status : $($vmstatus.count)”
$MyReport += Get-HTMLTable $vmstatus
$MyReport += Get-CustomHeaderClose
}
}
# —- check for vms with runtime questions —-
If ($ShowVMQuestions){
Write-CustomOut “..Checking for VMs with runtime questions”
$vmquestion = @($FullVM | Select Name, @{N=”Text”;E={$_.Runtime.Question.Text}} | where {$_.Text -ne $null})
If (($vmquestion | Measure-Object).count -gt 0) {
$MyReport += Get-CustomHeader “1″ “VMs with runtime questions : $($vmquestion.count)”
$MyReport += Get-HTMLTable $vmquestion
$MyReport += Get-CustomHeaderClose
}
}
# —- check for vms with low memory reservation —-
If ($ShowLowMemLimit){
Write-CustomOut “..Checking for VMs with memory reservation lower than assigned RAM”
$vmlowmemlimit = @($VM | Select Name, MemoryMB, @{N=”MemlimitMB”;E={Get-VMResourceConfiguration -VM $_ | %{$_.MemLimitMB}}} | where {$_.MemlimitMB -ne -1 -AND $_.MemlimitMB -lt $_.MemoryMB})
If (($vmlowmemlimit | Measure-Object).count -gt 0) {
$MyReport += Get-CustomHeader “1″ “VMs with low memory reservation : $($vmlowmemlimit.count)”
$MyReport += Get-HTMLTable $vmlowmemlimit
$MyReport += Get-CustomHeaderClose
}
}
I still want to add a routine that does some resource checks. I’ll add them to this post later.
Kind regards,
Rudolf Kleijwegt
about 4 months ago
Hey Alan – thanks for this mate. The report runs well until it hits Checking VC Services:
————-
14:48 ..Checking Host Alarms
14:48 ..Checking VM Alarms
14:48 ..Checking Cluster Configuration Issues
14:48 ..Checking VC Services
Get-WmiObject : Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESS
DENIED))
At C:\Documents and Settings\dan.tracey\Desktop\VC Diagnostics\vCheck.ps1:280 c
har:28
+ $Services = get-wmiobject <<<< win32_service -ComputerName $VISRV |
Where {$_.DisplayName -like "VMware*" }
14:48 ..Checking VC Error Event Logs
Get-WmiObject : Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESS
DENIED))
At C:\Documents and Settings\dan.tracey\Desktop\VC Diagnostics\vCheck.ps1:937 c
har:31
+ $ErrLogs = @(Get-WmiObject <<<=’” + $Conv
Date + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”TimeGenerated”;
E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message)
14:48 ..Checking VC Warning Event Logs
Get-WmiObject : Access is denied. (Exception from HRESULT: 0×80070005 (E_ACCESS
DENIED))
At C:\Documents and Settings\dan.tracey\Desktop\VC Diagnostics\vCheck.ps1:954 c
har:32
+ $WarnLogs = @(Get-WmiObject <<<=’” + $C
onvDate + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”TimeGenerate
d”;E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message )
14:48 ..Checking vmkernel logs for warnings
14:49 ..Sending Email
Exception calling “Send” with “1″ argument(s): “Failure sending mail.”
At C:\Documents and Settings\dan.tracey\Desktop\VC Diagnostics\vCheck.ps1:151 c
har:14
+ $mailer.send( <<<
———
I’m a bit of a PowerCLI beginner so all help is very much appreciated!
Dan
about 4 months ago
@Dan Tracey
The errors are coming from the part that is used to communicate to your vCenter server over WMI, if your current account has access to that servers then you will be fine, if not then all you need to do is put a username in the $SetUsername = “” bit, so if I set it to $SetUsername = “mydomain\me” then next time you run the script it will ask you for a username and password, enter the same username (mydomain\me) and the password.
The credentils will then be stored in an encrypted file so that every other time you run the script it will have the correct permissions.
A little complicated I know but it was the easiest way I could find of doing it.
about 4 months ago
@Virtu-Al
Hi Al – ever so sorry – I should have RTFM – all great now. Thanks again! Dan
about 4 months ago
Thank You Alan!
about 4 months ago
Hi Alan,
first of all I would like to say that you do a good job and your scripts help us to do our work better!
I find your new feature “Dead Lun Path” grate, but maybe there is a Bug.
The script told me that we have a problem with some vmhbas.
esx2f1.douglas-informatik.de vmhba1:0:1 Dead
esx2f1.douglas-informatik.de vmhba1:1:1 Dead
esx2f1.douglas-informatik.de vmhba1:2:1 Dead
That was right and we fixed the physical problem so far, but your script told us still the same problem. I can’t find any dead path at the service console.
Have you any idea?
Best Marcel
about 3 months ago
oh no…. The bug I reported for NTP checks if you have multi NTP servers didn’t make it into this version… (strange with all these daily checks etc, you only have 1 NTP configured in your environment??)
Any chance it can make it into V4, explain code on how to fix it was provided in the v2 section.
about 3 months ago
@bitsorbytes
Ignore that… just seen vCheck 3.1 posting…. doh!
about 3 months ago
Liking version 3, Al. One “issue”… I am not a power shell expoert, but line 485 appears to be incorrect ($VIServer = Connect-VIServer $VISRV). Since different credentials could be set (i.e. not use logged in user/domain), it apepars more arguments should be supplied here (I have crashed and burned updating it myself). Thoughts?
Charlie
about 3 months ago
@cxo
Again my PS savvy-ness is not great, but I came across a solution, almost from this URL: http://powershellcommunity.org/Forums/tabid/54/aff/5/aft/4295/afv/topic/afpg/1/Default.aspx
I could not use “$creds.Password”, but everything else worked when I put in “-Passwrd Clear-Text-PW”. So solution is not complete, but getting closer. Thoughts?