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
In the General Details section there will now be a count of the number of VMs which are powered on.
Inactive VMs count
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
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:
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:
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.
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:
VM CPU ready over x%
Any VMs with a CPU %RDY over the configurable amount will be displayed in the report as below:
I hope you enjoy these additions and find them as useful as I do.
Please leave your comments below !







about 4 months ago
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.
about 4 months ago
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?
about 4 months ago
@Robert-NL
Thanks, unfortunatly i do not have a 3.02 host and dont think this cmdlet works agains that version. Sorry
about 4 months ago
@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.
about 4 months ago
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?
about 4 months ago
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: 0×80070005 (E_ACCESSDENIED))
At :line:203 char:27
+ $Services = get-wmiobject <<<< win32_service -ComputerName $VISRV | Where {$_.DisplayName -like "VMware*" }
about 4 months ago
@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( <<<< )
about 4 months ago
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
about 3 months ago
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)
about 3 months ago
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!
about 3 months ago
I was able to get the script scheduled in Task Scheduler…
about 3 months ago
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?
about 3 months ago
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
about 2 months ago
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