vCheck v5

That’s right, its finally here, vCheck v5 has arrived !

If you have been using previous versions of this report then its time to update, I have added lots of cool new features and checks which make this report (even if I do say so) awesome !

Some of the highlighted features of v5 are:

Comments

Each section now has comments telling you why I think it may be an issue, there are often links to blog posts and useful information for further reading, an example is below:

image

Obviously for the experts among you these comments can easily be removed in the script by changing the $comments = $true to $false

Automatic searching for log warnings

There is now a handy link to both the VMware KB site and Google which will automatically search for the errors found on these sites, no longer do you have a reason for not investigating those errors !

image

Multiple new checks

There are so many new checks that I have now created a dedicated page on my site for this script which lists some basic information, this will of course change over time as more detail is needed and I hope to shoot some video soon showing how to change some of the key areas.

To access the page click the “Featured Scripts” area above and select “vCheck (Daily Report)” or click here.

image

Thanks

I have been bugging various people to help me with this script, whether it be for information or html help, thanks to everyone who helped me out and also to the beta testers.

To mention a few of the people specifically, thanks goes to:

Raphael Schitz – As always he has contributed some great checks for v5 and thought of areas I would never have.  Amazing job my friend.

Duncan Epping – I have bothered him more than once for clarification on the way things work, cheers mate.

Andy Grant – He did a great job helping me tidy up my HTML and add new areas.

The beta testers – you know who you are !

Sorry if I missed anyone !

87 thoughts on “vCheck v5”

  1. For a vCenter managing 4.1 hosts, add ‘Add-PSSnapin VMware.Vimautomation.Core -ea SilentlyContinue’ after the $Version statement to make it run.

  2. Hello. Thanks to Alan and everyone for the vCheck script! I have an issue where certain items where the username should be reported are blank. Like for newly created vm’s the username should show. Or like the snapshot section should show the user who created the snapshot. Some users show and some do not. Any idea why? Thanks again!

  3. Hi Al,

    Many thanks for this. I’d like to add a request for querying multiple vCenters with one run of the script. Actually, we have a number of standalone ESX servers which have to be queried individually so it would be great to query them all with one run of the script?

    Cheers.

  4. Just got this script however it stops on the section ..Checking Capacity Info and just sits there.

    We have a vCentre 4.1 managing 4.1 and 4.0 ESXi hosts

    Dave

  5. Pingback: vCheck v5++
  6. Hey Alan,

    I am only having one problem and that is the SMTP Portion.

    We set everything up right – noted the SMTP server – Enabled SMTP in the script. We did some testing with a common email.vbs script floating out there that works perfectly fine. Obviously its different code and it seems that this script does use .net (Obviously right). Whats the deal? Is there any reason that the vbs script would work over the .net one? Let me know because I dont want to have to set up more scripts to do what should already work fine. I dont like modifying scripts because I have a tendecy to break them LOL. Thanks Alan.

  7. All – I see some other folks having the same issue with the error of:
    The Connect-VISERVER Cmdlet did not work, please check you VI Server. Any concrete solutions? Some folks have posted a “try this” but not certain on results…..

    I am running this for Win 7 Pro 32 Bit / vSphere Powercli 4.1
    Against a ESXi.4.1 environment with virtual senter.
    I run the powercli as my elevated privs (different user) for the account to logon to vcenter.

    Additional details:
    [vSphere PowerCLI] C:\> get-host

    Name : ConsoleHost
    Version : 2.0
    InstanceId : 99490a9b-d1fc-4304-9014-a094ba977bf8
    UI : System.Management.Automation.Internal.Host.InternalHostUserI
    nterface
    CurrentCulture : en-US
    CurrentUICulture : en-US
    PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
    IsRunspacePushed : False
    Runspace : System.Management.Automation.Runspaces.LocalRunspace

  8. I have a situation where I manage some of the VM’s but not all of them. Is there a way to run this script against the vCenter but only have it checking against a smaller set of the esx hosts?

    I was thinking about creating a folder and putting the esx servers in that folder. Then I could create a user that only has permissions to those machines.?.?

    any ideas?

  9. Hi Sham,

    I’m trying to use your script to send attachment but it doesn’t work.
    I’m sure i do something wrong. Can you tell me where and how must i use the script ?

    Thank you,

    Olivier

  10. Hi Guys,

    Not sure if this has been posted but for all those with issues displaying the CSS in outlook 7, you can add the following modification to get the script to send out the body as an attachment:

    function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) {
    $mailer = new-object Net.Mail.SMTPclient($smtpserver)
    $msg = new-object Net.Mail.MailMessage($from,$to,$subject,””)
    $msg.IsBodyHTML = $false
    #modified to save body as attachment and send that out…
    $body | out-file -Filepath “.\report.html” -encoding “ASCII”
    $att = new-object Net.Mail.Attachment(“C:\VIplugin\report.html”) #change the path to wherever your running the scrupt from.
    $msg.Attachments.Add($att)
    $msg.body = $subject
    $mailer.send($msg)
    $att.dispose()
    }

    Not to discredit your work in any way Alan – its a fantastic script. Just hope this helps someone.


  11. Pantoufle:

    Hi,
    vcheck is under evaluation on my company
    Out of the Box, I’ve this error:
    Property ‘Reason’ cannot be found on this object; make sure it exists and is settable.à : ligne:1306 caractère:15+ $Details. <<<< Reason = $HostConfigIssue.Reason
    vCenter 4.0 U1ESX 4.0 U1
    Help will be apreciate because i’m a novice with PowerShell .

    I’m having the same issue. I checked all the prereq’s and I have powershell v2, power cli 4 u1, and vcenter 2.5 —

    I figured I’d post here before ripping that check out of the script.

  12. Great work Al, but I have a problem running it: (vSphere PowerCLI)

    Ampersand not allowed. The & operator is reserved for future use; use “&” to pass ampersand as a string.

    Any ideas?

  13. OK, I solved it by myself, the reason is that outlook 2007 doesn’t support some HTML css displaying, to solve it, just open the message in outlook2007, then press Alt+H+X+V, this means use a browser to view this message, then everything work fine!

  14. Thanks for your great script, but I found an issue regarding the HTML displaying: when I use outlook to get this HTML format mail, I click it and cannot found the yellow comment on top of each section, but when I use webmail to open it in a browser (IE or FF), I got all the content.

    Could you please reproduce this?

  15. Hi.. I solved my fault-tolerant server by changing the queries slightly

    at the $Failtools variable, the query was:
    $FailTools = $VM |Where {$_.Guest.State -eq “Running” -And ($_.config.ftinfo.role -ne 2) -And ($_.Guest.OSFullName -eq $NULL -or $_.Guest.IPAddress -eq $NULL -or $_.Guest.HostName -eq $NULL -or $_.Guest.Disks -eq $NULL -or $_.Guest.Nics -eq $NULL)} |select -ExpandProperty Guest |select vmname,@{N= “IPAddress”;E={$_.IPAddress[0]}},OSFullName,HostName,@{N=”NetworkLabel”;E={$_.nics[0].NetworkName}} -ErrorAction SilentlyContinue|sort VmName

    The query was changed to:
    $FailTools = $VM |Where {$_.Guest.State -eq “Running” -And ((get-view ($_.id)).config.ftinfo.role -ne 2) -And ($_.Guest.OSFullName -eq $NULL -or $_.Guest.IPAddress -eq $NULL -or $_.Guest.HostName -eq $NULL -or $_.Guest.Disks -eq $NULL -or $_.Guest.Nics -eq $NULL)} |select -ExpandProperty Guest |select vmname,@{N= “IPAddress”;E={$_.IPAddress[0]}},OSFullName,HostName,@{N=”NetworkLabel”;E={$_.nics[0].NetworkName}} -ErrorAction SilentlyContinue|sort VmName

    As you can see I added “-And ((get-view ($_.id)).config.ftinfo.role -ne 2)”. It’ll be a bit slower, but now it will also check if the current VM is a secondary FT server (for which the vmware tools info is unavailable).

    same goes for the query at $AllVMs (—- VM Disk Space – Less than x MB —-)

    old query:
    $AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq “poweredOn” -And ($_.Guest.toolsStatus -ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne “toolsNotRunning”)}

    new query:
    $AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq “poweredOn” -And ($_.config.ftinfo.role -ne 2) -And ($_.Guest.toolsStatus -ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne “toolsNotRunning”)}

    Here I added “-And ($_.config.ftinfo.role -ne 2)” because the $FullVM is already a get-view version for the VM..

    I now don’t get a false positive on the vmware tools issue and on the Disk has less than xx MB space left..

  16. Hi,

    vcheck is under evaluation on my company

    Out of the Box, I’ve this error:

    Property ‘Reason’ cannot be found on this object; make sure it exists and is settable.
    à : ligne:1306 caractère:15
    + $Details. <<<< Reason = $HostConfigIssue.Reason

    vCenter 4.0 U1
    ESX 4.0 U1

    Help will be apreciate because i'm a novice with PowerShell :D.

  17. Great script and report is nice and clean. Has alerted me to a bit if swapping my capacity management tools haven’t highlighted (vKernel)…. so somethign to investigate there.

    However, how long should this take? we run approx 600 VM’s on 36 hosts and it took around 7 hours?

  18. Love the script, works well, but minor issues as previously reported, can I add another request ?

    If you have a VM protected with FT, then some sections do not report correctly (Or report VM’s as having issues when it’s just because they are FT protected)

    Namely the sections
    VM’s with less than X Mb free – the secondary FT VM is reported here as having diskcapacity of 0mb and freespace of 0mb (because it’s the secondary)

    VM Tools Issues – again the secondary vm in an FT pair is reported to have VMTools issues

    These are minor issues and the script is being used live in our environment, Many thanks

  19. There was a version of the script a while back that would complete in our 100 host, 1500 VM environment in about 15-20 minutes. I am not sure what version that was, but it was prior to version 3. Version 3 increased the time to run to be 1 hour 45 minutes. Version 5 is at least 8 hours. I love the report, but that is just too long for us.

    Lots of stuff out there about how slow the Get-VM cmdlet is. Maybe it has to do with that?

  20. I noticed that the user column was blank for quite a few usernames for me. It looks like the Find-Username does not work when you have multiple domains. I enhanced it a little.

    Function Find-Username ($username){
    if ($username -ne $null)
    {
    if($username.split(‘\’).count -eq 2) {
    $NetbiosDomainName = $username.split(‘\’)[0]
    $SamAccountName = $username.split(‘\’)[1]

    #Find domain
    $objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
    $Domain = $objForest.Domains | ?{$NetbiosDomainName -eq $_.Name.Split(‘.’)[0]}

    #Find user
    $root = [ADSI]”LDAP://$($Domain.name)”
    $filter = (“(&(objectCategory=user)(samAccountName=$SamAccountName))”)
    $ds = new-object system.DirectoryServices.DirectorySearcher($root,$filter)
    $ds.PageSize = 1000
    $UN = $ds.FindOne()
    }
    If ($UN -eq $null) {
    Return $username
    }
    Else {
    Return $UN.Properties.displayname
    }
    }
    }

    You also have to change how find-username is called. For example

    From: (Find-Username (($_.Creator.split(“\”))[1])).Properties.displayname

    To: Find-Username($_.Creator)

    Calling it this way makes the username show up even if the user cannot be found in ad or they’re a local user.

    Also, have you considered using ConvertTo-HTML -Fragment? It makes this function a bit shorter.

    Function Get-HTMLTable {
    param([array]$Content)
    $HTMLTable = $Content | ConvertTo-Html -Fragment
    $HTMLTable = $HTMLTable -replace ‘<‘, “”
    Return $HTMLTable
    }

  21. I have a cluster with two hosts running ESX 3.5 for which we’re not going to get upgrades to 4.0 (don’t ask…). The VMs running in that cluster obviously don’t have the latest vHardware, so they show up in the ‘VMs with old hardware’-section of the report.
    This might be another option to improve on the script : you could check wether the VMs with old vHardware are indeed running on 4.0 hosts…

  22. I like this version of the report, but I think you need to tune some aspects of it. To run the report against my enviro took 6 hours (60 Hosts, 1300 VM’s). Specifically here are the sections that took the longest: 1. Checking Snapshots (99 Min.) 2. Checking VMs for swapping or Ballooning (54 Min.) 3. Checking VM CPU % RDY (20 Min.) 4. Checking Number of VMs per Datastore (70 Min.). For reference, v3 of your report takes about 40 min.

  23. WOW! Awesome script! Thank you!

    Is there a way a I can get it to tell me if there are serial and parallel ports connected to the VM (similar to CD and Floppies).

    Thanks!!
    Raul

  24. Hi,
    On the Clusters With Less Than 10 Slot Sizes report I get a line for my cluster but no figures. I reckon from available resources I shouldn’t even get a warning for this, I assume the lack of figures is causing an error allowing this line to be produced even though empty. Any idea why the figures don’t come through?
    Would also love a filter on the Hardware Version report line as I have virtual appliances I can do nothing about and would like to filter!
    Otherwise amazing script 🙂

  25. Wow, right again ! Although I’m not on blades, I do have Dell servers, the PE 2950 III’s to be precise. Yeah, I think it might be a good option to include some sort of filtering mechanism to ignore reporting the same information over and over again.
    Thanks for the feedback guys, you rock !

  26. Yeah there are also specific Dell errors which I filter for locally here, I may add a “do not include” for that part of the script too to make it easier for people

  27. JorisD , i’m the author of this part. I also get this issue when assigning chassis media tray in case of blade servers. I can get rid of this alarms with datastore rescan, it may work for you too. otherwise, we can modifiy the code to filter on usb path. tell us if you need so

  28. I just figured out that these are reported under Configuration – Storage Adapters as ‘Local USB CDROM’. I think it might be best to turn of Dead Lunpath checking in my case…

  29. Indeed, I didn’t have the latest version of PowerCLI installed on the host which ran the script.
    So i’ve upgraded to PowerCLI 4.0 U1 and all of the sudden I’m getting back a whole lot of Dead LUNPaths like these :
    usb.vmhba32-usb.0:0-mpx.vmhba32:C0:T0:L0
    any clue as to what these are ? Storage-wise the ESXi hosts connect to a couple of NFS stores on a NetApp filer. No local storage, no iSCSI, and no FC…

  30. As always : great stuff !
    I have a question, though : I have a 10 node cluster, each node runs ESXi 4.0 U1 and has 32GB of physical memory installed. However, in the “Hosts overcommitting memory”-section, they don’t have any values listes in the “TotalMemMB” column, so they all show up even if they have an average of about 17GB of TotalAssignedMemMB.
    Any idea why the reading for TotalMemMB (and TotalUsedMB too) is blank for my hosts ?
    (also, I noticed two small typo’s : it’s overcommitting (double T), and on line 715 it should say “please check youR Vi Server”)

    1. Thanks for the spelling issues, I will fix these in the next version.

      You are porbably not getting the figures because you dont have PowerCLI 4.0 U1, I have only seen this in a previous version of PowerCLI.

      Thanks for the comments !

  31. Thanks Alan! After fixing my corrupted credential file, I’m running it as a scheduled task against all our vCenter instances

  32. Pingback: Anonymous
  33. Well done once again Sir. Thank you for giving us such an amzing tool. I have used your previous version for a few months now and love it. The Capacity Planning section in v5 made my boss very happy.

    I am also having the same issue as others with the HTML displaying in outlook strangely. I am using office 2010, but others who have 2007 have the same issue.(1) My solution was to attach the HTML page to the email and (2)changing the text color of the headers from white to black. (3) I also added a static line to the header of the email with a link to a share where I store the daily reports. This way users can click right through to the historical reports.

    1. I edited the function “Send-SMTPMail” :
    function Send-SMTPmail($to, $from, $subject, $smtpserver, $body, $attachment) {
    $mailer = new-object Net.Mail.SMTPclient($smtpserver)
    $msg = New-Object Net.Mail.MailMessage($from,$to,$subject,$body)
    $msg.IsBodyHTML = $true
    $attachment = $Filename
    $msg.attachments.Add($attachment)
    $mailer.send($msg)
    }

    2. I also did as “rvdnieuwendijk” suggested and changed the .dsp color to: #000000

    3. On line 390 I added: Find older reports here: \\Servername\ShareName

  34. I also have an issue with the email report.. it doesnt appear that CSS is correctly presented in Outlook 2007/2010.. the titles for each section are blank and the colors for those titles are blank.. ideas?

  35. On the comment of why multiple VC’s….I currently have separate emails daily the same as you, but I like a weekly “summary” against all 4 VC’s with less information than I get daily that I can fw on to the interested parties. They can get a quick glance at total numbers, VM’s deployed, things like that. I’d be interested in the modified script if you don’t mind! v5 is working great!

  36. Hi Al, how do I interpret the following data ?

    Number of VMs per Datastore over 5 : 6

    The Maximum number of VMs per datastore is 256, the following VMs are above the defined 5 and may cause performance issues

    For one datastore, I see 13 VM mentioned that are running from this datastore.

    I thought in general one large datastore could contain all VM’s – perhaps it is much better to have as much datastores as there are VM’s – or is there a specific rule of thumb to calculate the number of datastores ? can you advise ?

    thanks

  37. @Virtu-Al No would rather one email per VC… makes it easier to manage and ‘adjust’ settings etc per each VC…. 🙂

  38. I added

    Add-PSsnapin VMware.VimAutomation.Core
    Initialize-VIToolkitEnvironment.ps1

    after the param statement

    I think it is working now, I did not yet receive this error.

  39. Al, I certainly must be doing something wrong …
    My tools: PowerCLI 4.01 / Powershell v2 / Windows 7 x64 RTM
    when running this script using powershell.exe .\vcheck5.ps1, I am able to specify the credentials on the VMWare vCenter Server v3.5 but then receive the following error message in mail :

    The Connect-VISERVER Cmdlet did not work, please check you VI Server.

    what do I need to do here to solve this specific issue, or can you guide me to a FAQ where this and all related issues are already described with a solution ?
    Thanks,

    Sven

  40. Ok, on the multiple VC’s here is where I am:

    At the moment I too run it against multiple VC’s, all I do is setup a scheduled task for each VC, whilst you may get 3 or 4 emails it is easier to keep things seperated in the view of the html.

    It also means you can run them all at the same time and therefore it wont take ages as if i make it work against multiple VC’s it will have to check the data against 3 vcs independantly and not at the same time, it takes long enough if you have a large infrastructure due to the amount of checks and a few issues with PowerCLI cmdlets anyway.

    Is this helpfull to anyone, what would you gain from running it against multiple vcs apart from a single email ?

    Just trying to understand the feature request 🙂

    Thanks for the comments !

  41. Thanks for the comments everyone, I will look into the HTML issue and see if I can come up with another way of doing it, might not be able to keep it so pretty though 😉

  42. Hi Al,
    I was really impressed by the first script you made- was trying to contact you in order to get some issues fixed -perhaps I should try v5 first, but where on this page is the download link ? thanks,

  43. As always – awesome work.

    I tried to run it in my lab which isn’t all that big. 1 vCenter, 2 ESX hosts, about 50 VMs (of which maybe 25-30 are active). It hangs up at “Checking Capacity info…” and doesn’t seem to get past it. I’ve let it go about 20 minutes before canceling it. I set that to false and it moved right past it and completes successfully.

    Other than that the script is great. I’ve tried every revision of this script and have been thrilled with the progress. Thank you for all that you do for the community!

  44. Absolutely awesome work Al. I love the ability to change the colours.

    Does anyone know how to get it displaying properly in Outlook? I know it’s not a script issue, it’s the way Word displays web content. On my iPhone it works just fine.

    Speaking of iPhones, would it be possible to configure the script for a section to enable/disable for iPhone display. I know you can add the line yourself but some new users might not know this.

    …and lastly, would it be possible to configure for multiple vCenters as request above and to send to multiple emails??

    Apart from that, this is just sensational. Hats off!!

  45. Troy,

    Yes there is but I would need to adjust the code a little, any chance you can drop me an email so I can send it to you directly please.

    Thanks

  46. Addition to my previous comment. The report displays nicely in IE and Firefox, but not as an HTML email in Outlook.

  47. Great Script!!! One question. We have 9 vCenters. Is there a way to make your vCheck script report on all of them without having to launch it 9 times?

  48. Great Script! Curiously, when I run it, the titles of the various sections are missing as are the comments. Am I missing something?

  49. Absolutely great Work Alan!!
    I found just one thing to think of –
    The “Num VM Per Datastore Check” looks for all VMs in a Datastore – I would suggest only to look for running VMs

  50. Definitely one of the most awaited updates . U Rock and the script is definitely going to help lot of VM Admins out there !!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.