PowerCLI: Daily Report V2

Firstly I would like to thank everyone who took the time to comment on my previous Daily Report script, I really appreciate the feedback and have never had so many comments !

Now onto V2…

This one will take a while longer to run than the last script but as its a scheduled task we are not really worried about that, we are hardly going to sit there and watch it running !

I think you will agree the results are worth the wait:

What’s new

  • Bug Fixes
  • Active VMs count
  • Inactive VMs count
  • DRS Migrations count and list
  • Correct NTP Server check for each host
  • VMs stored on local datastores
  • NTP Service check for each host
  • vmkernel warning messages for each host
  • VM CPU ready over x%
Bug Fixes

I have fixed the bugs which were mentioned in my previous posts comments, thanks to all for helping me find these.  I have also added a few other tweaks along the way to improve output etc.

Active VMs count

image

In the General Details section there will now be a count of the number of VMs which are powered on.

Inactive VMs count

image

In the General Details section there will now be a count of the number of VMs which are powered off.

DRS Migrations count and list

image

In the General Details section there will now be a count of the number of DRS migrations over the given timescale (configurable in the config section), these migrations will also be listed in the DRS Migrations section later in the report:

image

Correct NTP Server and service check for each host

In the config section of the script you must specify your correct ntp server name, the script will then check to make sure all your hosts are using this NTP server and that the NTP service is running, if they are not it will report on these as below:

image

VMs stored on local datastores

The script will check to see if you have any VMs which reside on local storage if they do it will report these.  At the top of the script you can add exclusions for things like templates or machines you know are allowed to be on local storage.

image

vmkernel warning messages for each host

Each host’s vmkernel log file will be checked and if any warning messages are being displayed these will be included in the report:

image

VM CPU ready over x%

Any VMs with a CPU %RDY over the configurable amount will be displayed in the report as below:

image

I hope you enjoy these additions and find them as useful as I do.

Please leave your comments below !

Check out the latest version here

Alan

Alan Renouf has a role of Automation Frameworks Product Manager at VMware responsible for providing the architects and operators of the cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/vipowershell and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

You may also like...

123 Responses

  1. Ian Martin says:

    Is there something similar to this for the VMWare View PowerCLI and View environment or will this work for it as well?

  2. Chris says:

    This looks a great script but doesn’t quite work for me. It generates a report but two errors come up as well which make me suspect I’m missing at least part of the report. The errors are as follows. I first installed vSphere PowerCLI 4.0.1 which I guessed was the right thing; the script doesn’t document its software dependencies.

    Get-WmiObject : Access denied
    At C:\ps\DailyReportV2.ps1:203 char:28
    + $Services = get-wmiobject <<<< win32_service -ComputerName $VISRV |
    Where {$_.DisplayName -like "VMware*" }
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

    Get-WmiObject : Access denied
    At C:\ps\DailyReportV2.ps1:633 char:28
    + $ErrLogs = Get-WmiObject <<<='” + $ConvDate +
    “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”TimeGenerated”;E={$_.
    ConvertToDateTime($_.TimeGenerated)}}, Message
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

    Get-WmiObject : Access denied
    At C:\ps\DailyReportV2.ps1:647 char:29
    + $WarnLogs = Get-WmiObject <<<='” + $ConvDat
    e + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”TimeGenerated”;E={
    $_.ConvertToDateTime($_.TimeGenerated)}}, Message
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

  3. Adrian says:

    I really like this script.. Thanks for putting the work into it, now if I can combine the two other VC’s we have into the single report that would be good (we have a vc for 2.5, 3.0, and 3.5) – no really good technical reason for it at the moment.
    Thanks again

  4. Jamie Lotz says:

    When I run this I’m getting:

    WARNING: There were one or more problems with the server certificate:
    * A certification chain processed correctly, but terminated in a root certificate which isn’t trusted by the trust
    provider.
    * The certificate’s CN name does not match the passed value.

    “Check Host Certificates” is unchecked in vCenter. Any ideas?

  5. grannysmyth says:

    I was able to get the script scheduled in Task Scheduler…

  6. grannysmyth says:

    I have one other question if you don’t mind. I am able to run the script from the command line using the following command:
    [vSphere PowerCLI] C:\scripts> .\vcheckv3.ps1 vmonster
    How do I schedule this in task manager? Power CLI is installed @
    “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\”

    Thanks!

  7. grannysmyth says:

    Great Script! Most everything is working except for when the script checks for created or cloned VM’s. I get the following error: Any ideas?

    Select-Object : Exception calling “FindOne” with “0” argument(s): “The specifie
    d domain either does not exist or could not be contacted.

    At C:\Temp\vcheckv3.ps1:625 char:188
    + $OutputCreatedVMs = @($VIEvent | where {$_.Gettype().Name -eq “Vm
    CreatedEvent” -or $_.Gettype().Name -eq “VmBeingClonedEvent” -or $_.Gettype().N
    ame -eq “VmBeingDeployedEvent”} | Select <<<< createdTime, @{N="User";E={(Find
    -Username (($_.userName.split("\"))[1])).Properties.displayname}}, fullFormatte
    dMessage)
    Select-Object : Exception calling "FindOne" with "0" argument(s): "The specifie
    d domain either does not exist or could not be contacted.
    "
    At C:\Temp\vcheckv3.ps1:625 char:188
    + $OutputCreatedVMs = @($VIEvent | where {$_.Gettype().Name -eq "Vm
    CreatedEvent" -or $_.Gettype().Name -eq "VmBeingClonedEvent" -or $_.Gettype().N
    ame -eq "VmBeingDeployedEvent"} | Select <<<< createdTime, @{N="User";E={(Find
    -Username (($_.userName.split("\"))[1])).Properties.displayname}}, fullFormatte
    dMessage)
    Select-Object : Exception calling "FindOne" with "0" argument(s): "The specifie
    d domain either does not exist or could not be contacted.
    "
    At C:\Temp\vcheckv3.ps1:625 char:188
    + $OutputCreatedVMs = @($VIEvent | where {$_.Gettype().Name -eq "Vm
    CreatedEvent" -or $_.Gettype().Name -eq "VmBeingClonedEvent" -or $_.Gettype().N
    ame -eq "VmBeingDeployedEvent"} | Select <<<< createdTime, @{N="User";E={(Find
    -Username (($_.userName.split("\"))[1])).Properties.displayname}}, fullFormatte
    dMessage)

  8. kevin says:

    Supply values for the following parameters:
    Credential
    Get-WmiObject : User credentials cannot be used for local connections
    At C:\code\VMware_Daily_Report.ps1:201 char:28
    + $Services = get-wmiobject <<<< win32_service -Credential $creds -Com
    puterName $VISRV | Where {$_.DisplayName -like "VMware*" }
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

    Get-WmiObject : User credentials cannot be used for local connections
    At C:\code\VMware_Daily_Report.ps1:631 char:28
    + $ErrLogs = Get-WmiObject <<<='” + $ConvDate + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”Ti
    meGenerated”;E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

    Get-WmiObject : User credentials cannot be used for local connections
    At C:\code\VMware_Daily_Report.ps1:645 char:29
    + $WarnLogs = Get-WmiObject <<<='” + $ConvDate + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=
    “TimeGenerated”;E={$_.ConvertToDateTime($_.TimeGenerated)}}, Message
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], Managemen
    tException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
    ommands.GetWmiObjectCommand

  9. Rob says:

    @Marshall
    I’ve got the same error. I also ran this (and also vCheck 3) script on VC 4.0 with ESX 3.5 and 4.0 hosts. When vCheck 3 starts with “..Checking Snapshots” the VMware Virtual Center service crashed. I tried a few times but the error stil exist. Now with vCheck its possible to disable some checks, so I disabled the Snapshot part and the script works fine.
    Does somebody know why the Virtual Center service crashed during the Snapshot report? When I run a Get-VM | Get-Snapshot i’ve got no problems

    Exception calling “ReadNextTasks” with “1” argument(s): “There is an error in X
    ML document (7, 203404).”
    At C:\Beheer\scripts\vCheck\vCheck3.0.ps1:420 char:45
    + $collection = $collectionImpl.ReadNextTasks( <<<< $tasknumber)
    Exception calling "DestroyCollector" with "0" argument(s): "The remote server r
    eturned an error: (502) Bad Gateway."
    At C:\Beheer\scripts\vCheck\vCheck3.0.ps1:436 char:34
    + $collectionImpl.DestroyCollector( <<<< )

  10. leeon says:

    hi,

    Really appreciate the efforts you took in developing this script. Can you please help me identifying why I am getting the below error .I am running this script form the vesi .

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    At :line:203 char:27
    + $Services = get-wmiobject <<<< win32_service -ComputerName $VISRV | Where {$_.DisplayName -like "VMware*" }

  11. Ben says:

    Hi Al, Great script..

    I’m seeing this error:
    Get-Stat : 4/11/2009 10:31:58 AM Get-Stat The metric counter “cpu.rea
    dy.summation” doesn’t exist for entity “My Server”.
    + $myObj.PercReady = [Math]::Round((($v | Get-Stat <<<< -Stat
    Cpu.Ready.Summation -RealTime | Where {$_.Instance -eq $cpunum} | Measure-Objec
    t -Property Value -Average).Average)/200,1)
    Get-Stat : 4/11/2009 10:32:30 AM Get-Stat The metric counter "cpu.rea
    dy.summation" doesn't exist for entity "AnotherServer".

    Only happening with 3-4 of our servers out of 300, so just wondering if it may be a data collection timeout issue?

  12. Virtu-Al says:

    @Hase3d
    One thing we have done here is create an exchange group to send it to, you should also be able to add a ; between each email address.

  13. Virtu-Al says:

    @Robert-NL
    Thanks, unfortunatly i do not have a 3.02 host and dont think this cmdlet works agains that version. Sorry

  14. Hase3d says:

    Hello, really nice script. Works like a charm except that I am having trouble to with the $EmailTo = “” I would like to have multiple mail recipiants but I get allot of errors when adding more mail adresses to that line? If I want to have more than 1 mail recipiant how should the line look?

  15. Robert-NL says:

    In the line of code:
    $NTPCheck = @(Get-VMHost | Select Name, @{N=”NTPServer”;E={$_ | Get-VMHostNtpServer}}, @{N=”ServiceRunning”;E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq “ntpd”}).Running}} | Where {$_.ServiceRunning -eq $false -or $_.NTPServer -ne $ntpserver})

    Get-VMHostNtpServer gives the error: “Index was outside the bounds of the array”
    on a VMware ESX Server version 3.0.2.

    I have not found a solution yet, but I wanted you to know about the problem.

  1. August 25, 2009

    […] ever wonderful Virtu-Al has released an update to his PowerShell Daily report. This script is beyond awesome in usefulness and should be required in any production VI […]

  2. August 28, 2009

    […] Virtu-Al » PowerCLI: Daily Report V2 – Version two of a handy PowerShell based VMware Environment Daily Report from VMware vExpert and PowerShell guru Alan Renouf What’s new/Bug Fixes * Active VMs count * Inactive VMs count * DRS Migrations count and list * Correct NTP Server check for each host * VMs stored on local datastores * NTP Service check for each host * vmkernel warning messages for each host * VM CPU ready over x% […]

  3. September 1, 2009

    […] a quick look at how the day is going to be, before you get into the office. You can see his post here Comments [0]Digg […]

  4. September 3, 2009

    […] Daily Report September 3, 2009 Posted by Matt Roblin in Uncategorized. trackback http://www.virtu-al.net/2009/08/18/powercli-daily-report-v2/ Possibly related posts: (automatically generated)Justin Broadrick Gives Some Details on the Alan […]

  5. October 12, 2009

    […] The script are based on Alan Renouf`s Daily Report script for PowerCLI. […]

  6. April 12, 2010

    […] can use PowerCLI to report on the status of guests and hosts. Check out Alan Renouf’s excellent PowerCLI Daily Report, for a really good example of how far you can […]

  7. February 19, 2011

    […] you are using my Daily Report script and want a nice output I have just received a cool tip from NiTRo over at […]

  8. December 27, 2012

    […] CPU Ready – http://www.virtu-al.net/2009/08/18/powercli-daily-report-v2/ […]

Leave a Reply

%d bloggers like this: