PowerCLI vCheck 5.40

The other day I noticed two bugs in version 5.38 of the vCheck script. This minor update resolves those bugs and adds a check for 4.1 hosts without Active Directory authentication configured.

# Version 5.40- bwuch: Host version greater than/equal 4.1.0 and AD Auth not configured
# Version 5.39- bwuch: bug fixes from 5.38 version

5.39 – Bug fixes to resolve issues with re-use of global variables in version 5.38 (a description of these bugs can be found here: http://enterpriseadmins.org/blog/scripting/powercli-vcheck-5-38/#comments)

5.40 – added check based completely on LucD’s Get-VMHostAuthentication function available here: http://www.lucd.info/2010/07/25/script-vsphere-4-1-ad-authentication/. This check looks for hosts running ESX/ESXi 4.1 or higher without Active Directory authentication setup. This check can be disabled by setting $ShowHostADAuth to $false

You can download the updated version here: vCheck5.40.ps1

Please feel free to leave a comment with any suggestions or problems you may encounter.

This entry was posted in Scripting, Virtualization. Bookmark the permalink.

11 Responses to PowerCLI vCheck 5.40

  1. vishy says:

    Great enhancements, in regards to show Cluster configuration issues, is there a way to exclude local storage mis-matched reporting?

    Thanks and Regards..

  2. Ed says:

    I’d like to suggest a couple of new additions to the very first blocK:
    1. The number of processor sockets in the environment
    2. The total vRAM in the environment (the sum of all of the allocated memory of all of the powered on guests).

    Thanks, and keep up the great work!!!

  3. @vishy, I tried originally to exclude the local disks, but the easiest way would be to exclude them by controller name. The problem with that method would be maintaining the list of controllers that have local storage in code. The other method I could see would be to look and see if that datastore exists on any other hosts — if not it could be excluded. I think that option is worse because it could exclude some datastores that actually need to be investigated.

    @Ed, there are MANY changes in vSphere 5.0 that are going to require many vCheck code updates. It seems the only one people want to discuss is licensing, and I total understand the need to check your actual numbers. The more I think about licensing, the more acceptable the change seems. Until I get around to adding this into vCheck, you can check out your license entitlements using Alan Renouf’s script here: http://www.virtu-al.net/2011/07/14/vsphere-5-license-entitlements/

  4. Parag Mehta says:

    I am getting following warning when running 5.40 version of vCheck script:

    10:21:44 AM ..Checking Hosts Dead Lun Path
    WARNING: ‘LunPath’ property is obsolete. Use ‘Name’ instead (it holds the same value).

    My environment has PowerCLI 2.x (Windows 7 Enterprise) with VMware PowerCLI 4.1.0 Update 1

  5. I have located this bug on line 1327 of vCheck 5.40. For now, even with this warning the correct data should appear on the report. If you want the warning to go away, you can change the text from $esxlun.Lunpath to $esxlun.name on line 1327 and it should disappear. I’ll make sure this bug is addressed in an upcoming version.

  6. Brian Black says:

    Nice job. Glad someone is keeping this script up to date. I also have a suggestion and a feature request. How difficult would it be to create broader sections with headings (General, Configuration, VM, Storage, etc) and add links at the top that take you to an anchor lower in the report? Also, how about addind a the ability to enumerate and report orphaned VMDK files similar to the code at http://www.lucd.info/2011/04/25/orphaned-files-and-folders-spring-cleaning – omitting the ability to DELETE datastores? The first suggestion is more cosmetic (and from a co-worker that received the generated report), but the second might be useful to those of us who actually read the report and make decisions based on the data.

  7. Brian Black says:

    We had someone deploy VMs from a template and configured them with an e1000 vNIC. I wanted to report any VMs that have a vNIC other than a VMXNET3 (or as specified). Here is some code I whipped up to report on all VMs with a “Legacy vNIC”. Hopefully the code comes through intact. Feel free to include this in the next version.

    # List VMs With Legacy VMs
    # Supported Values: Unknown,1000,Flexible,Vmxnet,EnhancedVmxnet,Vmxnet3
    $VMShowLegacyVNIC = $true
    $VMPreferredVNIC = “Vmxnet3”

    If ($VMShowLegacyVNIC){
    Write-CustomOut “..Checking for Legacy Network Adapters”

    $VMLegacyVNIC = @(Get-NetworkAdapter -VM $VM | Select @{Expression={$_.Parent};Label=”Virtual Machine”}, @{Expression={$_.Name};Label=”Adapter”}, @{Expression={$_.NetworkName};Label=”Port Group”}, @{Expression={$_.Type};Label=”Adapter Type”} | Where {$_.”Adapter Type” -cne $VMPreferredVNIC} | Sort @{expression=”Virtual Machine”;Ascending=$true},@{expression=”Adapter”;Ascending=$true})

    If (($VMLegacyVNIC | Measure-Object).count -gt 0 -or $ShowAllHeaders) {
    $MyReport += Get-CustomHeader “VMs with Legacy Network Adapter : $($VMLegacyVNIC.count)” “The following VMs are configured with a legacy virtual network adapter.”
    $MyReport += Get-HTMLTable $VMLegacyVNIC
    $MyReport += Get-CustomHeaderClose
    }

    }

  8. @Brian Black,

    I love the idea of adding some additional headings with quick links. At a minimum I want to re-arrange some of the checks so all the host/VM/datastore checks are outputted together. I’ll have to do some thinking on how to implement the headings…my HTML skills aren’t very good.

    I have two pieces of code ready to implement…orphaned file checker and top datastore by IOPS. Neither code block has made the cut yet. I run vCheck daily in my environment, but the orphaned file checker only gets ran once a month — because it takes about 3 hours to complete. That is as long as all the other checks combined! The IOPS check takes longer yet…if I come up with a way to run these that doesn’t break the clock I’ll be sure to squeeze it in.

    I’ve been thinking about code to check for VMXNET3, but what I really want is a listing of guest Operating Systems and a preferred NIC for each one. For example, if you have a legacy server that doesn’t support VMXNET3, there wouldn’t be a problem with having a E1000 driver in use. I’m thinking this would be a hash table with OS and preferred NIC but I haven’t wrote the code yet.

    I have another version of this script ready to publish (5.44) and should have it up in a week or so after I run it through a few additional test environments. It contains the BIOS cluster check and a couple other bug fixes.

  9. Ed says:

    I’d like to suggest another new feature. Similar to the Cluster CPU Allocation ratio, I’d like to see a “Cluster Memory Allocation ratio” section. Instead of cores, report on physical memory. Instead of vCPU_Count, report on “Total Guest Memory Allocation”. Instead of vCPU_per_VM, report “Allocated memory per VM” and then instead of “vCPU_per_Core”, report a ratio of “Allocated memory / Physical memory”.

    This should give us a nice snapshot of memory – how much overcommitment we have, and how much memory an average guest is using in each cluster. If we then trend this over time (not yet part of vCheck), we can see how much the average memory allocation is going up as new versions of guest operating systems come out or guest applications get fatter. As the ratio goes higher, not only are we more likely to get into the ballooning and swapping situations, but we’re also likely overpaying for vRAM since we’re allocating for memory that we can’t use.

    Thoughts?

  10. Ed says:

    I’ll follow up my own post with the code to implement this. Set the ShowMemClusterRatio variable to $true at the top of the script if you want this section in your report. Hopefully this doesn’t line-wrap itself to the point you can’t figure it out.

    # Cluster Memory allocation ratios
    if ($ShowMemClusterRatio){
    Write-CustomOut “..Checking Cluster Memory ratio”
    $FullClusterDetail = @()
    Foreach ($Cluster in $Clusters){
    $guestcnt,$clustervmemmb,$hostCount,$clustermem = 0,0,0,0
    Foreach ($ESXHost in ($Cluster |Get-VMHost |Sort Name)){
    $hostview = $ESXHost | get-view
    $guestvmemmb = 0
    foreach ($clustMemVM in ($ESXHost |Get-VM)){
    $guestcnt += 1
    $guestvmemmb += ($clustMemVM).MemoryMB
    }
    $hdwrMem = $ESXhost.MemoryTotalMB
    $hostCount += 1
    $clusterMem += $hdwrMem
    $clustervmemmb += $guestvmemmb
    }
    $ClusterDetails = “” | Select Name, Hosts, HostMemMB, Guests, vMb_Count,vMb_per_VM, vMb_per_HostMB
    $ClusterDetails.name = $Cluster
    $ClusterDetails.hosts = $hostCount
    $ClusterDetails.HostMemMB = $clusterMem
    $ClusterDetails.guests = $guestcnt
    $ClusterDetails.vMb_Count = $clustervmemmb
    $ClusterDetails.vMb_per_VM = ([math]::round(($clustervmemmb/$guestcnt), 2))
    $ClusterDetails.vMb_per_HostMB = ([math]::round(($clustervmemmb/$clusterMem), 2))
    $FullClusterDetail += $ClusterDetails
    }
    If (($FullClusterDetail | Measure-Object).count -gt 0 -or $ShowAllHeaders) {
    $MyReport += Get-CustomHeader “Cluster Memory Allocation ratio” “The following gives brief cluster level view of vMem and physical mem allocation ratios.”
    $MyReport += Get-HTMLTable $FullClusterDetail
    $MyReport += Get-CustomHeaderClose
    }
    }

  11. Pingback: EnterpriseAdmins.org » Blog Archive » PowerCLI vCheck 5.47 – Additional RAM checks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.