Introduction
vCheck is a PowerShell HTML framework script, the script is designed to run as a scheduled task before you get into the office to present you with key information via an email directly to your inbox in a nice easily readable format.
This script picks on the key known issues and potential issues scripted as plugins for various technologies written as PowerShell scripts and reports it all in one place so all you do in the morning is check your email.
One of they key things about this report is if there is no issue in a particular place you will not receive that section in the email, for example if there are no datastores with less than 5% free space (configurable) then the disk space section in the virtual infrastructure version of this script, it will not show in the email, this ensures that you have only the information you need in front of you when you get into the office.
This script is not to be confused with an Audit script, although the reporting framework can also be used for auditing scripts too. I don’t want to remind you that you have 5 hosts and what there names are and how many CPU’s they have each and every day as you don’t want to read that kind of information unless you need it, this script will only tell you about problem areas with your infrastructure.
What’s new
vCheck has been updated to be more community driven and easier to expand, the checks have been removed and put into separate plugins which make it easier for people to contribute.
The HTML output has been reformatted to work with newer versions of Outlook.
A Setup Wizard has been added for easy setup and no more need to reference the vCenter address as a parameter of the script.
As the plugins have been moved out it makes this HTML report framework easy to adapt to other PowerShell enabled products like VMware vCD, Sharepoint, Exchange, vShield, VMware View, SQL, Active Directory and more. – please contact me if your interested to start your own using this template.
A header image has been added to the HTML report.
And much much more.
Github
All scripts are now available via Github and can be modified as part of the Github website where I will approve the changes after checking, this enables everyone to get involved and add new features fast!
It also enables people to log issues in an easy way and control when they are fixed. Please do log your issues on the site rather than a comment on my blog.
To download the script check out the below example screenshot and click the “Download Zip” for each of the versions of vCheck, download links follow in this page for each of the versions.
Download vCheck
Currently there is a vCheck report for each of the following areas:
Download Link | Github Project | Example Output Page |
vCheck for vSphere | Click here | Click here |
vCheck for Exchange 2010 | Click here | Click here |
vCheck for vCD | Click here | Coming soon |
vCheck for SCVMM | Click here | Click here |
vCD Audit script | Click here | Click here |
vCloud Air Audit | Click here | Click here |
Cisco UCS | Click here | Clone the repo and check out the Example-Report.html in root |
Now follow the video below to set up the vCheck script.
Plugins
vCheck has been designed to add output from any script (.ps1 file) in the plugins folder, each one of these will be run in numerical or alphabetical order and the output included in the vCheck report. If you are not interested in the information for one of the checks it is highly recommended you remove the file as this will make the report faster.
For a great way to manage these make sure you check out Jake’s post here, he will show you how to use PowerCLI to easily check for new plugins and plugins which you do not have installed, you can even install them in a single command.
Headers
The Header.jpg in the root of the vCheck folder will be used and displayed in the title bar of the report (unless your email client does not support embedded base64 encoded images), this can be replaced with any image file of your choice but it is advised you stick to the same length and width as the current image.
A selection of headers can be found on the Headers page of this site.
Prerequisites for vSphere version of vCheck
The following will need to be installed for you to run this script and report on your VMware environment:
- PowerShell V2
- PowerCLI 5.01 or later version
- vCenter 2.5 or later version
Configuring the script
The first time you run this script it will go through a configuration menu, this configuration will be saved and used for all future runs of the script. If you want to go back through the configuration or you add new plugins to the script then please run the script with the –config parameter as follows:
.\vCheck.ps1 –configOutput File
Some people like to save a copy of the HTML for future reference or so they can go back and see when a problem started happening, to do this use the –OutputPath parameter and specify a location where the HTML will be saved, to do this run the script as follows:
.\vCheck.ps1 –OutputPath C:\vCheckOutput\DailyReportsRunning the script
The following video will show how to run the script for the first time and any subsequent runs after this:
Adjusting connection information
In some cases you will need to adjust the connection information used by the connect-viserver cmdlet to connect to your vCenter, this can be adjusted through the config wizard or if extra credentials are needed please edit the 00 Connection Plugin for vCenter.ps1 file in the 00 Initialize folder as below or use the New-VICredentialStoreItem to store connection credentials:
Before
$VIConnection = Connect-VIServer $VIServerAfter
$VIConnection = Connect-VIServer $VIServer –user “AlternateUsername” –Pass “Alternatepassword” –Protocol HttpsLearn more
Want to learn more about the vCheck Project? Recently I spoke about it at the PowerShell Summit, you can watch the video here:
FAQ
Q. How do I add multiple Email recipients ?
A. Edit the Global Variables.ps1 file and replace the line starting $EmailTo to the following:
$EmailTo ="user01@example.com,user02@example.com"Issues or feature requests?
If you have issues when you run this script or just wish it could do something different or new, add your thoughts to the github issues section here: https://github.com/alanrenouf/vCheck-vSphere/issues?state=open
Thanks, fixed
broken link
http://virtu-al.net/Downloads/vCheck/vCheck.htm
Hi Expert,
I am new in PowerShell . I have trying to write a script on collecting Average of CPU & memory of Custer Wise with each 5 min interval under multiple VCenters.
for example : out should be like
VcenterName ClusterName CPUAvg MEMAvg TimeStamp
Vcenter1 ABC001 4.7 42.3 20211123_000001
Vcenter1 ABC002 4.5 42.3 20211123_000001
Vcenter2 PQR002 3.9 39.8 20211123_000001
Vcenter2 PQR003 3.2 40.2 20211123_000001
Vcenter3 XYZ001 2.4 33.6 20211123_000001
Vcenter1 ABC001 3.7 42.3 20211123_000600
Vcenter1 ABC002 4.1 42.3 20211123_000600
Vcenter2 PQR002 3.1 39.8 20211123_000600
Vcenter2 PQR003 3.5 40.2 20211123_000600
Vcenter3 XYZ001 2.9 34.2 20211123_000600
Vcenter1 ABC001 4.7 42.3 20211123_000600
Vcenter1 ABC002 4.5 42.3 20211123_000600
Vcenter2 PQR002 3.9 39.8 20211123_000600
Vcenter2 PQR003 3.2 40.2 20211123_000600
Vcenter3 XYZ001 3.1 34.2 20211123_000600
Here I am trying to write the script for same. please help me out
# Import Modules
Get-Module -Name VMware* -ListAvailable | Import-Module
# Add PowerCLI Snap-in and PowerCLI Cloud Snap-in
Add-PSsnapin VMware.VimAutomation.Core -Erroraction Silentlycontinue
Enable-PSRemoting -Force
#Vcenters host names under “Vcenters.txt”
Connect-VIServer -Server ”Vcenterts.txt”
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
$clusters = get-cluster
$myClusters = @()
foreach ($cluster in $clusters) {
$hosts = $cluster |get-vmhost
[double]$cpuAverage = 0
[double]$memAverage = 0
Write-Host $cluster
foreach ($esx in $hosts) {
Write-Host $esx
[double]$esxiCPUavg = [double]($esx | Select-Object @{N = ‘cpuAvg’; E = {[double]([math]::Round(($_.CpuUsageMhz) / ($_.CpuTotalMhz) * 100, 2))}} |Select-Object -ExpandProperty cpuAvg)
$cpuAverage = $cpuAverage + $esxiCPUavg
[double]$esxiMEMavg = [double]($esx | Select-Object @{N = ‘memAvg’; E = {[double]([math]::Round(($_.MemoryUsageMB) / ($_.MemoryTotalMB) * 100, 2))}} |select-object -ExpandProperty memAvg)
$memAverage = $memAverage + $esxiMEMavg
}
$cpuAverage = [math]::Round(($cpuAverage / ($hosts.count) ), 1)
$memAverage = [math]::Round(($memAverage / ($hosts.count) ), 1)
$ClusterInfo = “” | Select-Object Name, CPUAvg, MEMAvg
$ClusterInfo.Name = $cluster.Name
$ClusterInfo.CPUAvg = $cpuAverage
$ClusterInfo.MEMAvg = $memAverage
$myClusters += $ClusterInfo
}
$myClusters | Export-Csv -Path .\Custerwise_AVGCPUMEM_Metics_$((Get-Date).ToString(“yyyyMMdd_HHmmss”)).csv -NoTypeInformation
Dear Sir :
Great day to you,
May i seek your advise how to run this script step by step?
many thanks
Did anyone ever comment or where you able to fix this? I have the same issue!
Hi All, I have requirement to run vcheck report at one time on multiple vcenters with same credentials. Please let me what need to be added or modified in vcenter connections settings.
Hi, thanks for your great work with the scripst.
Just a simple question the report work on the vCenter 7.0? had did tested anyone?
Is there any updates with powercli version 12
Yes, you can adjust the script in the plugin
Hi Alan
That’s a great tools to get the infra health. I am using this for long time. With the current script, is there any way to get the datastore usege details irrespective of threshold. Since I am not getting any storage usage report unless its hit the threshold.
In theory yes it could be adjusted to do so but it’s not planned by me so you would need to do the work
any response for my query
Hi Alan,
i am using you script since last 4 years, it’s very nice and useful.
Just one query. It is possible instead of generating the HTML output can we generate the report in word or excel format.
Hi Alan, Frederic,
I have enabled ‘VMKernel warnings’ plugin and renamed the PS script file as well however I did not get the report output. Could you please advise how to enable this to get a report
Hi,
Did you manage to filter by Cluster?
Single Storage VM’s Plugin: Trying to use a wildcard (*) for certain local datastores, but fails everytime. Thoughts?
parsing “*-INF-SPS00*” – Quantifier {x,y} following nothing.
At C:\BIN\VCHECK\Plugins\60 VM\30 Single Storage VMs.ps1:20 char:52
+ … ere-Object {$_.Name -notmatch $LDSDoNotInclude -and -not $_.summary.m …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException
The capacity Report, I dont understand what it represent.
Estimated Num VM Left (MEM)
What does this mean?
running this with powercli 6.5 R1 against vcasa 6.5 produce several errors. can you figure out what is the issue?
—————————- 1
Method invocation failed because [System.Object[]] does not contain a method named ‘op_Division’
At D:\scripts\vCheck-vSphere-master\Plugins\20 Cluster\71 Capacity Planning.ps1:38 char:7
+ $VmCpuAverage = $CluCpuUsageAvg/($cluvmlist.count)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Division:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
—————————————— 2
Exception calling “Add” with “2” argument(s): “Item has already been added. Key in dictionary: ‘HostSystem-host-58’
Key being added: ‘HostSystem-host-58′”
At D:\scripts\vCheck-vSphere-master\Plugins\60 VM\45 VMs needing snapshot consolidation.ps1:13 char:31
+ … ach-Object {$htabHostVersion.Add($_.MoRef,$_.config.product.version)} …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentException
——————————————— 3
Get-NetworkAdapter : The input object cannot be bound to any parameters for the command either because the command
does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline
input.
At D:\scripts\vCheck-vSphere-master\Plugins\60 VM\200 VMs on ephemeral portgroup.ps1:13 char:7
+ $VM | Get-NetworkAdapter | Where-Object {$_.NetworkName -contains $Ep …
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (VMware.Vim.VirtualMachine:PSObject) [Get-NetworkAdapter], ParameterBin
dingException
+ FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetNetwor
kAdapter
Hi,
i want to monitor VCSA 6.5, can you please help me out here.
So this is my 2nd run with this script and for some reason the License portion of the report is not matching what is in Web client.
Yes I want to know is there any module or plugin to check the replication status of vm and also the xclarity critical alerts
Is it just me or is anyone having issues with the credentials.xml file being saved while running with powercli 6.5 ?
Like to know this as well.
Hey Alan, your suggestion for Adjusting connection information isnt working with the script version 6.25.
I guess there’s a syntax error in the line.
In your new script there is:
$VIConnection = Connect-VIServer -Server $VIServer -Port $Port
So, how is the correct syntax to fit in:
$VIConnection = Connect-VIServer $VIServer –user “AlternateUsername” –Pass “Alternatepassword” –Protocol Https
BR
Han
I have the same issue
Sachin, on a jump host, I wouldn’t run it on the VC as it will take away valuable resources from the vCenter servers
Can the vCheck report run from jump host that has connectivity to vcenter server OR has to be configured on the vCenter server?
Happy New Year All:
I am having issues with the Scheduled Task only with VASA vCenter 6.5. My scripts have been working on all other versions with no issue. The issue only exists when running against vCenter 6.5. I can run the script manually via PowerCLI with no interruptions or issues, but the Scheduled Task just continues to run with no stopping in sight and nothing happens.
Has anyone gotten the Scheduled Task to work with vCenter 6.5?
Thanks,
Mike
Did you ever get a response?
Is there any plugin or module that vCheck will check hardware status as well? Something to notify about real hardware issues??
From powercli ,how to create user , networkpool in vcloud director > kindly provide solution for this
We have scale setup, while we are calling few queries like get-ciuser , Get-OrgVdc getting timed out as we have some 50000 users , is there any way can we call page wise . Kindly help me in solution
Oh that’s a shame, I guess his blog disappeared.
The “Example output page” for the Cisco UCS goes to a parked domain page
http://www.foobartn.com/assets/examples/example-report.html
Has this script been updated to work with versions => 6.0 and 6.5 and current versions of PowerCLI??
From what the comments say, it appears not…??
Hi Alan,
Could help me in getting the credentials to add in the parameter
$newPScreds = Get-Credential -message “Enter the NSX manager admin creds here:” $newPScreds | Export-Clixml nsxMgrCreds.xml
can you give me example of it
I am using the EndScript.ps1 to rename and move the created files to the website location on an existing IIS Server. I use Port Switching and it works great. rename the file to index.html and move it to the needed location.
I am trying to send the vcheck report using my google apps settings:
$SMTPSRV = “aspmx.l.google.com”
# Would you like to use SSL to send email?
$EmailSSL = $false
But it is failing with this error:
**Exception calling “Send” with “1” argument(s): “Service not available, closing transmission channel. The server
response was: 4.7.0 [58.137.164.50 15] Our system has detected that this message is”
At C:\Scripts\vCheck\vCheck.ps1:902 char:2
+ $smtpClient.Send($msg)
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SmtpException**
Does anyone know what I’m doing wrong here?
I have try it with the port 25 selected and SSL set to true but it still fails.
Hello All ,
May I know if we are going to setup the web page on IIS server , how
should we do that since the htm name will be changed everytime
Thanks
Yes, I’m having issues with PowerCLI 6.5 as well. The script wasn’t completing fully since the upgrade, and attempt to fix it by starting from scratch is giving me headaches. When running it manually, it’s prompting me for my credentials on several of the scripts over and over, preventing me from having it work as a scheduled task again.
I will most likely be submitting this as a bug on the GitHub site today.
yes i get the same does it ever finish ?
yep just used it then
It sort of works for me and I’m running 6.0 U2. I run into some issues with the ” 95 of 109 – uncontrolled snapshot mode” It just kind of hangs there a for a while. Not sure if it is me or the script that it is calling.
this might be a stupid question but does vcheck work with vmware 6.0 update 2 and 6.5 ?
Hi,
I am getting a couple of errors running the script:
Get-NetworkAdapter : The input object cannot be bound to any parameters for the command either because the command
does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline
input.
At D:\Scripts\vCheck-vSphere-master\Plugins\60 VM\200 VMs on ephemeral portgroup.ps1:5 char:8
+ ($VM | Get-NetworkAdapter | where {$_.NetworkName -contains $EphemeralPG} | Sele …
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (VMware.Vim.VirtualMachine:PSObject) [Get-NetworkAdapter], ParameterBin
dingException
+ FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetNetwor
kAdapter
and:
Get-VIEvent : Cannot bind parameter ‘Entity’. Cannot convert the “VMware.Vim.VirtualMachine” value of type
“VMware.Vim.VirtualMachine” to type “VMware.VimAutomation.Sdk.Types.V1.VIObject”.
At D:\Scripts\vCheck-vSphere-master\Plugins\70 Misc\108 SRM RPO Violations.ps1:45 char:77
+ $Events = Get-VIEvent -MaxSamples $MaxSampleVIEvent -Entity $RPO …
+ ~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-VIEvent], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetEvent
Hi @Marc, I can confirm this behavior when using PowerCLI 6.5. It is caused by a change from powershell snapins to modules in PowerCLI 6.5. You can resolve this by adding the following line between lines 53 and 54 in the Plugins/00 Initialize/00 Connection Plugin for vCenter.ps1 file (right above the if statement checking for the snapins):
Import-Module vmware.vimautomation.core -ErrorAction SilentlyContinue
vCheck isn´t working with PowerCLI 6.5 anymore. Downgraded to 6.3 and it´s working again. Can anyone confirm?
Hi
When i execute the script on my vsphere client installed on a remote system i get the below error
ERROR 1:
File C:\Users\IBM_ADMIN\Desktop\SRR\vCheck.ps1 cannot be loaded. The file C:\Us
ers\IBM_ADMIN\Desktop\SRR\vCheck.ps1 is not digitally signed. The script will n
ot execute on the system. Please see “get-help about_signing” for more details.
.
At line:1 char:13
+ .\vCheck.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
ERROR 2: after i set the execution policy to bypass mode
The '<' operator is reserved for future use.
At C:\Users\IBM_ADMIN\Desktop\SRR\vCheck.ps1:116 char:14
+ < <<<
+ CategoryInfo : ParserError: (<:OperatorToken) [], ParseExceptio
n
+ FullyQualifiedErrorId : RedirectionNotSupported
Question: what is the procedure to un-register the script
Question: how to provide the smtp auth
Thanks
Harish
Hi David,
vCheck does not change any setting on your servers. It just wants to know what the correct settings are so that it can check them against your servers.
Regards,
Robert
Hi,
Very new to this, but I would like to run the vCheck script against me new VMware install (production) I started the script and it went through the setup but some of the questions looked like they were going to change the config of my server (NTP for instance) which I do not want it to. Am I miss reading this?
Regards
David
Great article. I have really enjoyed your article. You show how to create vcheck report . It is really very helpful. I have done by the help of your article. I am using PowerCLI 5.0.1 and Its is working fine . Thanks for sharing .The way you explained each and everything is really great . Thanks once again .
To power on all VMs on Venter or esxi, first connect to vcenter or esxi using powercli, type the command
Get-VM | Start-VM
For powering on only powered off VMs
Get-VM | ?{$_.PowerState -eq “PoweredOff”} | Start-VM
Hope this helps.
Regarding the the Cisco UCS vCheck. The new version of the Cisco UCS power tool 2.02 has a change in the powershell module name: CiscoUcsPS is now Cisco.UCSManager. I updated this in my copy of the script, but you may want to update it or make note of it in the readme.
Keep the scripts and reports on your machine or setup a separate ‘automation’ server to keep all that information, you can then simply point the script to the vc appliance.
Hello, I am having issues with the script not saving credentials. Can someone help me.
can any body post how to powering on virtual machines using powershell script (automation process)
Hi Alan,
Have you got a solution to use vcheck on a VMware Appliance ?
Regards
Rémi
No all. I was wondering if you can run individual. ps1 script files individually in Powershell and view the output In Powershell as well.
Awesome tools.
Thank you all from
A Nub from Cali
I believe these were valid bugs actaully; I submitted them to the GitHub page and they have been corrected in the code, but thank you for the reply.
Upgrade your Powershell version. Sounds like you are still on v2. Use WMF 5.0 and the ($obj).count problem goes away.
Your other issues might also. I don’t know that off the top of my head.
A couple little bugs that I have found while creating/editing plugins and cant seem to track down where to fix in the code:
1. If your [count] is less than 2, it does not work correctly. I have a plugin with only 1 result and the [count] is blank.
2. If your results table only contains 1 column, it strips the column name and replaces it with an asterisk (*)
(I’ve found a few other bugs that I have corrected, for example: The plugin report does not seem to actually display in order. This may be due to having $ListEnabledPluginsFirst enabled, so I added “,Name” to the sort options)
I’m getting the same error. Did you get this figured out?
Hello Alan, This is awesome script.. I was looking for a script which specifically give me details like.
How many svmotions in last 30 days, source and destination datastore and user details who moved it.
Had some issue with 98 vSwitch Security.ps1. It was giving me a: “snap-in ‘VMware.VimAutomation.VdsComponent’ is not installed on this computer.” error.
Made some changes in the following part which fixed it for me:
# Check Power CLI version. Build must be at least 1012425 (5.1 Release 2) to contain Get-VDPortGroup cmdlet
$VersionOK = $false
if (((Get-PowerCLIVersion) -match “VMware vSphere PowerCLI (.*) build ([0-9]+)”)) {
if ([int]($Matches[2]) -ge 1012425) {
$VersionOK = $true
# Add required Snap-In (nope, its a module)
if (!(Get-Module -name VMware.VimAutomation.Vds -ErrorAction SilentlyContinue)) {
Import-Module VMware.VimAutomation.Vds
}
}
}
Using PowerCLI 6.0R3.
I thought I just leave it here.
Is there a way i can configure the vCheck report to show output in datacenter wise instead of Issue wise report ?
Is there a way i can configure the vCheck report to show output in datacenter wise instead of Issue wise report ?
Hello alan,
I am getting this foreground color error.
Write-Host : Cannot bind parameter ‘ForegroundColor’. Cannot convert the “#FFFF8C00” value of type “System.Windows.Media.Color” to type “System.ConsoleColor”.
At D:\Scripts\vCheck\vCheck.ps1:659 char:42
+ Write-Host $lang.pluginBegin -foreground $host.PrivateData.WarningForegroundColo …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Write-Host], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WriteHostCommand
Can you please let me know what can be changed.
Thanks
vKar
Getting duplicates on everything as well. Any idea why?
The given path’s format is not supported.
At ————–\vCheck-vSphere-master\vCheck.ps1:767 char:16
+ $embedReport | Out-File -encoding ASCII -filepath $Filename
+ $embedReport | Out-File -encoding ASCII -filepath $Filename
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Out-File], NotSupportedException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
the HTM file was failing to be created. it was trying to write the ipaddress:port# into the file name. not sure if that was the problem.
Change the variable in the row 758 – works for me!!
$Filename = $Env:TEMP + “\” + $VIServer + “_vCheck_” + $Date.Day + “-” + $Date.Month + “-” + $Date.Year + “.htm”
Hello Alan / All , Will it possible to get the OrgVDC details in 07 vApp Details plugins in vCD vCloud air Audit?
Awesomescript.I need a small help. Will it possible to get the out in this format. Org Name/VDCs Name/# of VMs/CpuLimitGhz/MemoryLimitGB/StorageLimitGB/CpuCountSizeGB/MemoryAllocationMB in one line. i tried to merge 07 vApp Details + 10 ORG VDCs list but its not working…
See this come up with when some of the plugins run. Anyone know how to fix it?
Get-ChildItem : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
facing issues with host alarm, some cleared the alarm from the vcenter level , so how i can get the real hardware alarm from the each host through powercli
Hey Alan,
I’m getting following error, would you able to help me fixing the errors?
I’m using PCLI 5.1 R1, PS 2, vCenter 5.1 U1, ESXi hosts 4.1 U2 & 5.1 U1
Get-View : Cannot validate argument on parameter ‘VIObject’. The argument is null or empty. Supply an argument that is not null or empty and then try
the command again.
At F:\Scripts\vCheck\Plugins0 Connection Plugin for vCenter.ps1:92 char:21
+ $alarmMgr = get-view <<<< $serviceInstance.Content.alarmManager
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
12:08:27 AM Collecting Detailed VMHost Objects
12:09:47 AM Collecting Detailed Cluster Objects
12:09:48 AM Collecting Detailed Datastore Objects
You cannot call a method on a null-valued expression.
At F:\Scripts\vCheck\Plugins0 Connection Plugin for vCenter.ps1:101 char:70
+ $VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars <<<< (0)
+ CategoryInfo : InvalidOperation: (Chars:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Hey Alan,
I’m getting following error, would you able to help me fixing the errors?
I’m using PCLI 5.1 R1, PS 2, vCenter 5.1 U1, ESXi hosts 4.1 U2 & 5.1 U1.
Get-View : Cannot validate argument on parameter ‘VIObject’. The argument is null or empty. Supply an argument that is not null or empty and then try
the command again.
At F:\Scripts\vCheck\Plugins0 Connection Plugin for vCenter.ps1:92 char:21
+ $alarmMgr = get-view <<<< $serviceInstance.Content.alarmManager
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
12:08:27 AM Collecting Detailed VMHost Objects
12:09:47 AM Collecting Detailed Cluster Objects
12:09:48 AM Collecting Detailed Datastore Objects
You cannot call a method on a null-valued expression.
At F:\Scripts\vCheck\Plugins0 Connection Plugin for vCenter.ps1:101 char:70
+ $VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars <<<< (0)
+ CategoryInfo : InvalidOperation: (Chars:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
can it customized to get the info for the last month ??? need your support please
Hi,
I am using vcheck on vmware and the plugin for snapshot information don’t return value for creator. I cant figure out why it is empty. I have not modify the plugin just run it.
Hope if you can help me out here.
.:: Niklas
The only error I am getting running the script against SC VMM is below. Will appreciate any help to fix this please.
Missing expression after unary operator ‘-‘.
At C:\vCheck\Plugins13 Hyper-V Integration Components Version.ps1:83 char:3
+ – <<<< Query "SELECT * FROM Msvm_ComputerSystem WHERE EnabledState=2 AND NOT Caption LIKE 'Hosting Computer System'"
+ CategoryInfo : ParserError: (-:String) [], ParseException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
This finally worked for me when I removed the *if (Get-…….. conditions at the top of the script file.
When running the initial vCheck.ps1, a large proportion runs correctly but have the below errors. Any ideas?
Method invocation failed because [System.Object[]] doesn’t contain a method named ‘CreateCollectorForTasks’.
At C:\_pir\vCheck\Plugins2 Snapshot Information.ps1:80 char:62
+ $collectionImpl = Get-View ($taskMgr.CreateCollectorForTasks <<<< ($filter))
+ CategoryInfo : InvalidOperation: (CreateCollectorForTasks:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
You cannot call a method on a null-valued expression.
At C:\_pir\vCheck\Plugins2 Snapshot Information.ps1:83 char:45
+ $collection = $collectionImpl.ReadNextTasks <<<< ($tasknumber)
+ CategoryInfo : InvalidOperation: (ReadNextTasks:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\_pir\vCheck\Plugins2 Snapshot Information.ps1:99 char:34
+ $collectionImpl.DestroyCollector <<<< ()
+ CategoryInfo : InvalidOperation: (DestroyCollector:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Method invocation failed because [System.Object[]] doesn't contain a method named 'CreateCollectorForTasks'.
At C:\_pir\vCheck\Plugins2 Snapshot Information.ps1:80 char:62
+ $collectionImpl = Get-View ($taskMgr.CreateCollectorForTasks <<<< ($filter))
+ CategoryInfo : InvalidOperation: (CreateCollectorForTasks:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
You cannot call a method on a null-valued expression.
At C:\_pir\vCheck\Plugins2 Snapshot Information.ps1:83 char:45
+ $collection = $collectionImpl.ReadNextTasks <<<< ($tasknumber)
+ CategoryInfo : InvalidOperation: (ReadNextTasks:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\_pir\vCheck\Plugins2 Snapshot Information.ps1:99 char:34
+ $collectionImpl.DestroyCollector <<<< ()
+ CategoryInfo : InvalidOperation: (DestroyCollector:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
10:47:34 AM ..finished calculating Snapshot Information by Alan Renouf, Raphael Schitz v1.1
10:47:34 AM ..finished calculating Datastore Information by Alan Renouf, Jonathan Medd v1.2
10:47:34 AM ..finished calculating Map disk region event by Alan Renouf v1.1
10:47:34 AM ..finished calculating Hosts in Maintenance Mode by Alan Renouf v1.1
10:47:34 AM ..finished calculating Hosts Not responding or Disconnected by Alan Renouf v1.1
10:49:08 AM ..finished calculating Hosts Overcommit state by Alan Renouf v1.1
10:49:09 AM ..finished calculating Hosts Dead Lun Path by Alan Renouf, Frederic Martin v1.1
10:50:49 AM ..finished calculating Created or cloned VMs by Alan Renouf v1.1
10:50:59 AM ..finished calculating Removed VMs by Alan Renouf v1.1
10:50:59 AM ..finished calculating VMs with CPU or Memory Reservations Configured by Dan Jellesma v1.0
10:51:23 AM ..finished calculating ESXi Inode Exhaustion by Matthias Koehler v1.0
I am having this error below running the vCheck scripts for SCVMM. This happens on “001 SC VMM Connection Plugin.ps1”
WARNING: SC VMM PowerShell cmdlets not available, the script is terminating
Hi, For some reason I got error:
Cannot convert argument “0”, with value: “VimApi_50.ManagedObjectReference”, for “SearchDatastoreSubFolders_Task” to type “VimApi_51.ManagedObjectReference”:
“Cannot convert the “VimApi_50.ManagedObjectReference” value of type “VimApi_50
.ManagedObjectReference” to type “VimApi_51.ManagedObjectReference”.”
At C:\scripts\vCheck-vSphere-master\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Task <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
Exception calling "WaitForTask" with "1" argument(s): "Value cannot be null.
Parameter name: moRef"
At C:\scripts\vCheck-vSphere-master\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMw
are.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
vCenter 5.1. update 1C
Any ideas? Thanks!
@Joey If you edit the — Connection Plugins for VCenter in the plugins folder on line 30 change it to the following
$VIConnection = Connect-VIServer $VIServer –user “User” –Pass “Password” –Protocol Https
(The information between the Quotes needs to be changed. This will then allow you to connect using different credentials) and allow it to be run unattended. The only problem with this is your password is in Plain text as the XML generation seems not to be working. But this is a good workaround.
Great script, but I have a problem. Trying to insert user and pass so it can be ran unattended but downloaded script isn’t close to matching above posted. Tried inserting in several places but no luck. Any ideas? Thanks.
Hi Alan
Is there any way to run vCD vCheck with read-only access to vCloud Director?
The only accounts that I have been able to run it with are the system administrator users and I don’t see any way to make an account with global read-only access.
Any help appreciated 🙂
Do you know how I can get plugin “19 Guests with less than X MB free” to sort by % free instead of Number of Disks? I modified it to add the percentage free but it’s still sorting weird. Thanks!
Nevermind. Found the issue. I hadn’t downloaded it all as a .zip and, thus, was missing the subfolders.
Totally read only, this is more of a policy question, EG this script will search for any VMs that are above the allowed vCPUs
Curious. I have yet to run only because i was not completely sure if the script would modify something. I am under the impression this is a read-only script and will not make any changes. The line that worries me is “Define the maximum amount of vCPUs your VMs are allowed [2]:”
I removed PowerCLI and reinstalled it again, that fixed the issue. It still takes a few hours to run but it finishes running.
Hi Fredo
I ran into this at a different plugin, it went away when I installed the latest (v5.5) PowerCLI.
I don’t know what I could be doing wrong, but anytime that I try to run this, I’m getting a bunch of errors and it just exits. I’m running it on a 2012 server with PowerCLI 5.5 installed. Here’s the type of errors I’m getting:
PS C:\support\scripts\vcheck> .\vcheck.ps1
Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. Do you want to run C:\support\scripts\vcheck\vCheck.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is “D”): R
At C:\support\scripts\vcheck\vCheck.ps1:118 char:18
+
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:124 char:18
+
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:209 char:54
+ Cod …
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:211 char:11
+
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:215 char:64
+ <span class="full …
+ ~
The '<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:218 char:13
+
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:221 char:68
+ <span class=" …
+ ~
The '<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:224 char:11
+
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:229 char:56
+ W …
+ ~
The ‘<' operator is reserved for future use.
At C:\support\scripts\vcheck\vCheck.ps1:231 char:13
+
+ ~
The ‘
Hi all
Just finished installing vCheck on a vSphere 5.5 vCenter. Fantastic tool – cheers Alan!
Here’s a couple of snags i ran into in case it saves someone else some effort 🙂
– Use the vSphere 5.5 PowerCLI (currently VMware-PowerCLI-5.5.0-1295336). The older 5.1 version will run but one or more checks will hang mysteriously.
– I think there’s a problem with the PowerCLI call that vCheck uses to retrieve VM hardware version, it returns ‘0’ for hardware version ’10’ for me, which means VMs will be included in the report when they are in fact up to date.
– We had problems with the header image not being included in the report, which appeared to be due to Style.ps1 being called before $HeaderImg had been populated – I just moved it below the function that builds the image variable.
Erick – any reply on this question? I am seeing the same behaviour when running it. Just sits there at calculating General Information…
Any idea how to fix this?
How would I change the port and set the smtp username and password for sending this via e-mail?
Afraid not. I haven’t had a chance to take a look at this in detail yet.
I see from the example you indicated that I can save the html output to a folder, but it’s not working for me. Do I have to indicate a file name along with the folder location to save the HTML in a file?
Thank you so much for this modification! This is exactly what I needed to see. Do you know how I can get this to sort by % free instead of Number of Disks?
Did you have any luck on this? I got the same issue
Already linked on this page 🙂
when we get the vCheck for vCD
Any thoughts on being able to pass-thru parameters when executing the script? For example I have multiple virtual centers and want to be able to pass-thru the server name. e.g. ( .\vCheck.ps1 –server vcenter1). This way I can still use all the same “base” configuration except point it to a different vCenter when it runs.
When running vCheck it gets stuck in ..finished calculating General information by Alan Renouf, Frederic Martin v1.2. it stays there for hours, even left it overnight but nothing happens beyond this line.
Since upgrading to PowerCLI 5.1 R2 my snapshot oversize script is now returning 0GB size and 0% oversize for all of the snapshots. Did anyone else get this and know a quick fix?
I had a need to show which disks were below a percentage, the plugin #19 showed disks below a fixed size, which we had many small disks in Redhat. I changed the script as follows:
# Start of Settings
# VM Disk space left, set the percentage amount you would like to report on
$MBFree = 20
# End of Settings
$MyCollection = @()
$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq “poweredOn” -And ($_.Guest.toolsStatus -ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne “toolsNotRunning”)}
$SortedVMs = $AllVMs | Select *, @{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
ForEach ($VMdsk in $SortedVMs){
Foreach ($disk in $VMdsk.Guest.Disk){
$Details = New-object PSObject
$DiskCapacity = 0
$DiskFreeSpace = 0
$DiskCapacity = [math]::Round($disk.Capacity/ 1MB)
$DiskFreeSpace = [math]::Round($disk.FreeSpace / 1MB)
$DiskPercentage = ($DiskFreeSpace / $DiskCapacity * 100)
if ($DiskPercentage -lt $MBFree) {
$Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty
$Details | Add-Member -Name “Diskpath” -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name “DiskCapacity(MB)” -MemberType NoteProperty -Value $DiskCapacity
$Details | Add-Member -Name “DiskFreeSpace(MB)” -MemberType NoteProperty -Value $DiskFreeSpace
$Details | Add-Member -Name “Disk Free %” -MemberType NoteProperty -Value (“{0:n2}” -f $DiskPercentage)
$MyCollection += $Details
}
}
}
$MyCollection
$Title = “Guests with less than $MBFree %”
$Header = “VMs with less than $MBFree % : $(@($MyCollection).count)”
$Comments = “The following guests have less than $MBFree % Free, if a guest disk fills up it may cause issues with the guest Operating System”
$Display = “Table”
$Author = “Alan Renouf/Bill Pendleton”
$PluginVersion = 1.1
$PluginCategory = “vSphere”
Let me know if you can use this.
Bill
I fixed this by replaceing the SizeMB on line 42 of the 02 Snapshot Information.ps1 with @{n=’Size MB’;e={“{0:N2}” –f $_.SizeMB}}. Now it does two deciomal places and adds a comma.
Hi Guys, I’m new to vCheck. Ran the script first time and got loads of errors, but reports came up nicely. Can anyone tell me how to resolve these errors or shall I ignore these erros.
Sorry for the long one.
The server certificate is not valid.
WARNING: THE DEFAULT BEHAVIOR UPON INVALID SERVER CERTIFICATE WILL CHANGE IN A
FUTURE RELEASE. To ensure scripts are not affected by the change, use
Set-PowerCLIConfiguration to set a value for the InvalidCertificateAction
Get-View : 9/7/2013 6:16:38 PM Get-View View with Id ‘VirtualMachine
-vm-280’ was not found on the server(s).
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins2 Snapshot Informati
on.ps1:88 char:18
+ $vm = Get-View <<<< $_.Entity
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutoma
tion.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\52 Datastore Consiste
ncy.ps1:9 char:55
+ $Datastores = $VMHosts | Get-Datastore <<<<
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\52 Datastore Consiste
ncy.ps1:10 char:110
+ $problemDatastoresObject = $VMHosts | ForEach {Compare-Object
$Datastores ($_ | Get-Datastore <<<< )} | ForEach {$_.InputObject} | Sort Name
| Select @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it
is null.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\52 Datastore Consiste
ncy.ps1:10 char:78
+ $problemDatastoresObject = $VMHosts | ForEach {Compare-Object
<<<< $Datastores ($_ | Get-Datastore)} | ForEach {$_.InputObject} | Sort Name
| Select @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Compare-Object], ParameterBind
ingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.PowerShell.Commands.CompareObjectCommand
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\52 Datastore Consiste
ncy.ps1:9 char:55
+ $Datastores = $VMHosts | Get-Datastore <<<<
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\52 Datastore Consiste
ncy.ps1:10 char:110
+ $problemDatastoresObject = $VMHosts | ForEach {Compare-Object
$Datastores ($_ | Get-Datastore <<<< )} | ForEach {$_.InputObject} | Sort Name
| Select @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it
is null.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\52 Datastore Consiste
ncy.ps1:10 char:78
+ $problemDatastoresObject = $VMHosts | ForEach {Compare-Object
<<<< $Datastores ($_ | Get-Datastore)} | ForEach {$_.InputObject} | Sort Name
| Select @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Compare-Object], ParameterBind
ingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.PowerShell.Commands.CompareObjectCommand
The term 'Get-VDSwitch' is not recognized as the name of a cmdlet, function, sc
ript file, or operable program. Check the spelling of the name, or if a path wa
s included, verify that the path is correct and try again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\80 DvPG with less tha
n x Ports Free.ps1:6 char:22
+ $vdspg = Get-VDSwitch <<<< | sort Name | Get-VDPortgroup
+ CategoryInfo : ObjectNotFound: (Get-VDSwitch:String) [], Comman
dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The term 'Get-VDPortgroup' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\80 DvPG with less tha
n x Ports Free.ps1:11 char:22
+ $PG = Get-VDPortgroup <<<< $i
+ CategoryInfo : ObjectNotFound: (Get-VDPortgroup:String) [], Com
mandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The term 'Get-VDPortGroup' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\vCheck-vSphere-master\vCheck-vSphere-master\Plugins\98 vSwitch Security.p
s1:35 char:16
+ Get-VDPortGroup <<<< | % {
+ CategoryInfo : ObjectNotFound: (Get-VDPortGroup:String) [], Com
mandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Had the same on my environment. My quick fix was to change the way it replaces contents of the path string (File “79 Find VMs in uncontrolled …” / Line 8):
From:
$Path = ($vm.Summary.Config.VmPathName).Split(‘/’)[0] -replace “[\[\]]”, “” -replace ” “, “\”
To:
$Path = ($vm.Summary.Config.VmPathName).Split(‘/’)[0] -replace “\[“, “” -replace “\] “, “\”
Whilst running this just now I got lots of errors in the “79 Find VMs in uncontrolled snapshot mode.ps1:11 char 38” plugin, they all said “cannot find path \xx.xx.xx.xx@443\\\A\B\C”.
The reason is that the names of our VMs in vSphere have spaces in them like “Win7 test” and this causes the plugin to look for “…\Win7\test” instead of “…\Win7 test”.
I downloaded and ran the plugins, but the snapshot plugin is throwing an exception. Any Ideas?
Get-Snapshot : Cannot validate argument on parameter ‘VM’. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\Scripts\vCheck-vSphere-master\Plugins2 Snapshot Information.ps1:112 char:34
+ $Snapshots = @($VM | Get-Snapshot <<<< | Where {$_.Created -lt (($Date).AddDays(-$SnapshotAge))} | Get-SnapshotSummary)
+ CategoryInfo : InvalidData: (:) [Get-Snapshot], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetSnapshot
Great script. It does magic in a blink of eye. Thanks.
$snapshotUserException =” *username*”
I’m having trouble with the snapshot removed or creation plugin, the user exception wont work, I’m entering the user as domain\username but it’s being ignored. Any ideas as to what I’m doing wrong?
A quick fix for those who are not skilled at modifying powershell code so they can hide any user with veeam in their name change $snapshotUserException =” *Veeam*”.
If you want an additional user to be excluded/hidden then create another variable such as $snapshotUserException2 =” *backupuser*”, then add this into your match rule (shown below):
(get-view (get-view ServiceInstance -Property Content.EventManager).Content.EventManager).QueryEvents($EventFilterSpec) | ?{$_.FullFormattedMessage -match “Remove snapshot” -and $_.userName -notmatch $snapshotUserException -and $_.userName -notmatch $snapshotUserException2} | Select createdTime, @{N=”User”;E={$_.userName}}, @{N=”VM Name”;E={$_.vm.name}}
I ran an older vCheck as well as the latest version for a couple of days. I am still testing but one issue is the newer vCheck was not showing any of the vCenter events to the older checks were showing. I did a Band-Aid fix and have added the variable $VCEventAge =7 into the plugin “23 VI Events.ps1” to get my 7 days for errors. Are any other plugins coded this way whereby variables are referenced before they are set?
Corrections for Syslog script – “51 Syslog Name.ps1”
@($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq ‘VMware ESXi’} | Select-Object Name,@{Name=’SyslogSetting’;Expression = {(Get-VMHostAdvancedConfiguration -VMHost $_ -Name Syslog.global.logHost).Values| Where {$_ -eq $SyslogServer}}})
Hello,
What are the minimum permissions required at VC ti run vCheck?
Thanks
Mandeep
Awesome, would love to see a NetApp version of vCheck!
Just started playing with this, and it is great. Thank you! I’m working on some updates to plugins and a new set of plugins for NetApp storage. If anyone else is working on NetApp plugins, let me know.
Has anyone done one of these for SQL server or IIS? I think these two additions would be widely used.
A plugin to know how many vms per cluster, how many vms are up and donw…after you can add what you need 🙂
# Start of Settings
#End of Settings
$MyObj = @()
ForEach ($cluster in get-cluster)
{
$Details = “” | Select Cluster, VMs, VmsUP, VMsDown
$Details.Cluster = $cluster
$Details.VMs = (get-cluster $cluster | get-vm).count
$Details.VMsUP = (get-cluster $cluster | get-vm | where { $_.PowerState -eq “PoweredOn” }).count
$Details.VMsDown = (get-cluster $cluster | get-vm | where { $_.PowerState -eq “PoweredOff” }).count
$MyObj += $Details
}
$Rapport = @($MyObj)
$Rapport
$Title = “Inventaire des vms”
$Header = “Inventaire des VMs par Cluster”
$Comments = “Inventaire et status des VMs dans chaque cluster”
$Display = “Table”
$Author = “Eric Le Nézet”
$PluginVersion = 1
$PluginCategory = “vSphere”
I am trying to run the initial config:
.\vCheck.ps1 –config
and receive the following error message:
# Enable License Reporting? [$true]:
Index operation failed; the array index evaluated to null.
At D:\My.fil\Tools14-CMS\VM\PowerCLI-Scripts\-MyStuff\vCheck\vCheck.ps1:25 char:4
+ $Question = $file[$Line]
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArrayIndex
[]:
Method invocation failed because [System.Object[]] doesn’t contain a method named ‘op_Subtraction’.
At D:\My.fil\Tools14-CMS\VM\PowerCLI-Scripts\-MyStuff\vCheck\vCheck.ps1:48 char:4
+ $Line ++
+ ~~~~~~~~
+ CategoryInfo : InvalidOperation: (op_Subtraction:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
Cannot convert the “System.Object[]” value of type “System.Object[]” to type “System.Int32”.
At D:\My.fil\Tools14-CMS\VM\PowerCLI-Scripts\-MyStuff\vCheck\vCheck.ps1:55 char:3
+ $out += $File[$Endline..($file.count -1)]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : ConvertToFinalInvalidCastException
# If you use a proxy to access the internet please specify the proxy address here, for example http://127.0.0.1:3128 else use $false
I’m trying to configure multiple users to hide from the removed snapshot plugin.
any idea how to go about it ?
for example i want to hide s-veeam and localdomain\backupuser ?
thank you very much.
Now vCheck is on Github please raise any issues on the Github site in the issues section, this makes it easier to track and assign as needed.
Hi
I used this line in a CMD file I created and it works
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” “& “C:\scripts\vCheck\vCheck.ps1″
for some reason there are playing with
‘ compare to ”
I am using powershell 2.0
good luck all and thanks for this amazing script.
Haim
Thanks Alan and everyone for this great tools. The only thing I would love to see is a log folder about how the script did when it ran.
Hi,
Great Script!!!
I use 6.15 and I see every entry in every section twice in the output.
e.g
Hosts which are in a disconnected state will not be running any virtual machine worloads, check the below Hosts are in an expected state
host1.domain.local notResponding
host1.domain.local notResponding
Regards
Stefan
The part “Adjusting connection information” should be corrected. “GlobalVariables.ps1” does not contain line 40 with $VIConnection. Instead “00 Connection Plugin for vCenter.ps1” at line 26 should be used.
@Nick,
Thanks Nick. I hadn’t, but had just spotted an old post from Alan mentioning the | separator and have made the changes. Much neater than the Foreach loop!
@ChrisLawrence did you use multiple NTP servers using a pipe symbol (|)?
First I would like to say thanks to everyone who uses this script, everyone who has left a comment and a big thanks to those of you who have added your own plugins here. I am concious that this information was not getting plugged back into the script as fast as i would like so i wanted to make some changes to make that easier.
From now on you can add changes and fix issues by looking at this post: http://www.virtu-al.net/2013/06/19/now-everyone-can-contribute-to-vcheck/
Thanks, and I hope this will take vCheck to the next level!
Module 79 currently has an issue – has a defined path for vm datastore instead of variables
Hi Alan,
Just a quick one. The NTP Server check doesn’t seem to like more than one value in the $NTPServer variable. I had to put a ForEach loop in so that it checks against each value in the variable. Once I did that it seemed to work fine.
Thought i’d let you know so that you might change it in a new version!
Many thanks,
Chris.
I’m using 5.1 with vcheck for a quite long time. Every morning I get my little report in my email. I’ve just been in touch with 2 littles bugs in some plugin. If you search for my previous comments, you will find the way to correct it.
I am going to 5.1 in the next few weeks so am interested if we know how to keep the script running… I quite like my morning email capsule from vCheck.
i did it without problem…can you tell us how you create your scheduled task?
Try with : in action put in script/command powershell.exe
and in “argument” (the first option under command/script) -f vcheck.ps1 (with full path)
Tchô
Finaly i split the vcheck :
– infra vcheck with all script about datacenter
– vm vcheck with all script about vm
next step check only selected clusters …
I have the exact same issue. Did you ever get this resolved?
Hi,
Next step … select a cluster and it wil be perfect 🙂 Datacenter search is long long long when you have a lot of vm/cluster. I would like to exclude/select only specific cluster in the datacenter…will search and post a com if i did it 🙂
No I have not gotten around this yet, i can run the report manually, but not as a scheduled task, nor can i create the xml file like you
Hi everybody,
I am unable to edit $VIConnection line, i dont find the line in vCheck.ps1 file?
Did you ever fix this? I have always loved VCheck but trying to get it to work in 5.1 as a nightmare. No matter what contation of credentials I use it will not create the XML file. Any ideas?
I do not think it would fail out the script. I’ve been meaning to try it out on ours here since we have a similar dual setup and would like to send out a customer-limited report. We already have two accounts, one global (read-only) and one whose access begins at the secondary datacenter (read-only). Just need to set up the account on the script vm we use. Will let you know if it works for me when I get a chance to try it out.
One caveat to this, I have severely hacked my copy of vCheck to make it run on different profile sets. I do not recall modifying anything that would effect what we are trying but cannot guarantee it.
Hope this helps!
-ChrisJ
I’m not clear on this. What I need to do is to exclude reporting on all of the vms, datastores, and information in one of the two datacenters in vCenter. For example, if I had a prod and a test datacenter and I only wanted to report on prod.
When you say two separate accounts do you mean that I would create an account for prod that had no rights to see the test datacenter? If so, wouldn’t that just fail out the script?
Thanks for the reply!
-Joe
As you know, vmware5.1 use the Single Sign On and the user identification has gone to the username@fulldomainname or fulldomainname\username format. (example. John.Smith@somecompany.com or somecompany.com\John.Smith. My Question is this;
1.) the windows scheduled task does not seem to take that format, or is assuming/truncating it to somecompany\john.smith. This results in failure to login, thus hanging the process. is there a method or workaround to use vCheck in a 5.1 environment?
Could you create two separate accounts for use, one for each datacenter?
Does anyone know if there is a way to exclude a datacenter? We have two datacenters in vcenter and one of them belongs to another group. We would like to report seperately but I haven’t seen a way to make this happen.
Any help would be appreciated.
Thanks,
Joe
check the no.of connections to the VC using powercli command- $global:DefaultVIservers,if there 1 session already then you end up with double data, try using disconnect-viserver * -confirm:$false
Hi all, this is a great script/plugin etc, thanks for all the work Alan.
Running latest version of vCheck, What I would like to know is following, is it possible to exclude via user exception VM’s that are created/cloned and removed? I am thinking something similar to how there is a user exception for snapshots removed and created. Reason for this is the report is being flooded both the “VMs Created/Clone” & “VMs Removed” section of the report due to the way the Commvault Simpana Virtual Server backup with SnapProtect works. Once a SnapProtect job is executed CV mounts up the snap from the array and actually indexes the snaps, this entails adding and removing Vm’s from the Snap Volume. This is done by service account which means same user executing this in vSphere. So if it’s possible to have a “user exception” style exclusion for this 2 plugins would be great.
I reply to myself, the change is done in the 00 Connection Plugin for vCenter ps1 file, and it works fine, one last thing, how can i encrypt the file?, because of the user and pass appears in text, and for security reason I will like to encryp it
Thanls
Hi all
The script seems to run fine for me, it sends me to my email accout the file with the info, but when i execute the scheduled task it promt me withe the box for user and password, i put a line in 40, but it keep on ask me for the credential
any help?
Thanks
When running the script I am getting the following error:
writeErrorStream : True
Exception : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.VimException: 5/1/2013 4:45:38 PM Get-View
View with Id ‘VirtualMachine-vm-2183’ was not found on the server(s).
TargetObject :
CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {0, 1}
PSMessageDetails :
This is happening after:
..finished calculating General Information by Alan Renouf, Frederic Martin v1.1
Can anyone advise what is going on?
Thanks in advance.
JD
is there a way I can save this file rather than emailing?
vCheck -config asks your about the timeserver to use on the local machine. if you are using a public NTP server, default is pool.ntp.org, make sure you are able to reach the server on port 123 for UDP communication.
Regards,
Surya
Is the information about “Adjusting connection information” is still valid? or I have to look for the connection information in some other file?
Regards,
Surya
Great script. Anyone think of a reason why all my data is doubled up and in some cases, like with datastores, tripled or quadrupled?
Thanks
Can vCheck provide peak cpu and memory utilization by cluster? I need the current resource (cpu and mem) allocation and peak utilization information to determine if the cluster has sufficient capacity to meet new VM resource requirements.
I take it back, it still doesn’t work. I haven’t figured it out yet.
If you move creating the PSOBject into the 2nd for each, it won’t print the 2nd disk’s information.
If the PSObject is defined in the 1st for each, it will print each drive multiple times for the same host.
I’ll keep tinkering see if I can make it work.
We had an issue with ’19 Guests with less than X MB free.ps1′ where if a VM had multiple disks under the alert level, it would list the VM twice with 2 disks.
I fixed this by moving the creation of $Details into the nested foreach loop.
Contact me if you need more details.
I use v6.15 and think its great for keeping tabs on my environment.
I had a scheduled power interruption on one of the power feeds to my host last night (it has two power inputs so nothing went down). I did this at 4:52 pm MST. In my vCheck report that autogenerated the next morning, it shows a line from Plug in #36 – Host Alarms v1.1 that this happened, but it shows the time as 10:52 pm. When I log into the vSphere client to see the alert, it shows the correct time of 4:52 pm.
MST is -7 although with daylight savings weirdness maybe that accounts for why vCheck reports it off by 6 hours. ???
Have I missed some time setting parameter that I should have made or …?
Thanks
-Randy-
Ah – found the answer myself 🙂 – The function used in the plugin is available in PowerCLI 5.1
Hi All – Can anyone suggest why the Storage I/O control module is reporting that we don’t have SIOC enabled when we actually do ? – Other than that the report is working excellently.
Thanks a lot for this script, pretty handy!
Is it really an issue if our VMs are thick provisioned though? Just saying, lol.
When I put in the $VIConnection = Connect-VIServer $VIServer –user “AlternateUsername” –Pass “Alternatepassword” –Protocol Https it craps out and start giving me errors and no detail in the report. Please help!!
Todd
Where in the 00 Connection Plugin for vCenter do you add it? I cant find it.
You can also remove the streams..
http://stackoverflow.com/questions/728143/ignore-security-warning-running-script-from-command-line
Hi Alan, I’m getting “Swapfile location NOT SET” even though an explicit datastore is configured for every host at the cluster level. Any ideas why the script doesn’t recognise this..?
set-executionpolicy bypass
Hi there, about the datastore information plugin. I also would like to display some extra information about the datastores like “provisioned space” and “used space” Is there a way to parse this in the existing plugin?
Thanks,
Erik
The following plugins took longer than 60 seconds to run, there may be a way to optimize these or remove them if not needed.. How to fix this ? Please help
Wondering if anyone is having the same problem as myself. I cannot get the VmClonedEvent to return any results on the ‘created or cloned VMs’ script. The other events show results as expected, but any VM’s that have been created from cloning another do not show.
# Start of Settings
# Set the number of days to show VMs created for
$VMsNewRemovedAge =30
# End of Settings
$VIEvent = Get-VIEvent -maxsamples 10000 -Start ($Date).AddDays(-$VMsNewRemovedAge)
$OutputCreatedVMs = @($VIEvent | where {$_.Gettype().Name -eq “VmBeingCreatedEvent” -or $_.Gettype().Name -eq “VmClonedEvent” -or $_.Gettype().Name -eq “VmBeingDeployedEvent”} | Select
createdTime, UserName, fullFormattedMessage)
$OutputCreatedVMs
$Title = “Created or cloned VMs”
$Header = “VMs Created or Cloned (Last $VMsNewRemovedAge Day(s)): $(@($OutputCreatedVMs).count)”
$Comments = “The following VMs have been created over the last $($VMsNewRemovedAge) Days”
$Display = “Table”
$Author = “Alan Renouf”
$PluginVersion = 1.1
$PluginCategory = “vSphere”
Finaly with return train, I’ve debugged the 71 plugins !
I think you have created a cluster in your environement (as me) but actually no esx host are attached to it.
So you can easy modify 71 plugins by adding in line 11 this :
if ($cluv.Summary.NumEffectiveHosts -gt 0) {
and close the } just after $capacityinfo += $clucapacity nearly the end.
Ok Finally after one hour of debuging in the train, I’ve found the problem with script 64. you need to change line 34 and the following ones like this :
if (($global:DefaultVIServer).Version -cge “5.1”){$searchSpec = [VMware.Vim.VIConvert]::ToVim51($searchSpec)}
elseif (($global:DefaultVIServer).Version -cge “5”){$searchSpec = [VMware.Vim.VIConvert]::ToVim50($searchSpec)}
elseif (($global:DefaultVIServer).Version -cge “4.1”){$searchSpec = [VMware.Vim.VIConvert]::ToVim41($searchSpec)}
elseif (($global:DefaultVIServer).Version -eq “4.0.0”){$searchSpec = [VMware.Vim.VIConvert]::ToVim4($searchSpec)}
$searchSpec.details.fileOwnerSpecified = $true
if (($global:DefaultVIServer).Version -cge “5.1”){$dsBrowserMoRef = [VMware.Vim.VIConvert]::ToVim51($dsb.MoRef)}
elseif (($global:DefaultVIServer).Version -cge “5”){$dsBrowserMoRef = [VMware.Vim.VIConvert]::ToVim50($dsb.MoRef)}
elseif (($global:DefaultVIServer).Version -cge “4.1”){$dsBrowserMoRef = [VMware.Vim.VIConvert]::ToVim41($dsb.MoRef)}
elseif (($global:DefaultVIServer).Version -eq “4.0.0”){$dsBrowserMoRef = [VMware.Vim.VIConvert]::ToVim4($dsb.MoRef)}
In fact it’s missing the test for release 5.1.
alan can you update the script in the distribution ?
You’re not alone, I’m getting the same error. First I’ve thought in a corruption of my ps1 files, so I’ve completely reinstalll vCheck 6 but the error is still here. I’m running vCenter version 5.1.0 build 799731 and my esxs are in version 5.1.0 build 914609
Is there a way to run vCheck without having the security prompt for each plugin file? I have my execution policy set to unrestricted and do not want to set it to bypass. Thanks.
Thanks a lot for such a great script! We are running 6.15 and one of the things I noticed are these 2 errors while looking at the logs:
****************************************************
2:21:47 PM ..finished calculating Powered Off VMs by Adam Schwartzberg v1.1
2:21:47 PM ..finished calculating Guest OS Pivot table by Frederic Martin v1.1
2:21:48 PM ..finished calculating Unwanted virtual hardware found by Frederic Ma
rtin v1.1
2:22:57 PM ..finished calculating Snapshot removed by Raphael Schitz, Frederic M
artin v1.2
Cannot convert argument “0”, with value: “VimApi_50.ManagedObjectReference”, fo
r “SearchDatastoreSubFolders_Task” to type “VimApi_51.ManagedObjectReference”:
“Cannot convert the “VimApi_50.ManagedObjectReference” value of type “VimApi_50
.ManagedObjectReference” to type “VimApi_51.ManagedObjectReference”.”
At C:\scripts\vCheck\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Ta
sk <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
Exception calling "WaitForTask" with "1" argument(s): "Value cannot be null.
Parameter name: moRef"
At C:\scripts\vCheck\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMw
are.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
2:22:58 PM ..finished calculating Snapshots Oversize by Raphael Schitz v1.1
*************************************************
and this:
*************************************************
2:24:10 PM ..finished calculating Disk Max Total Latency by Raphael Schitz, Fred
eric Martin v1.1
2:24:10 PM ..finished calculating Datastores in Maintenance Mode by Frederic Mar
tin v1.1
2:24:10 PM ..finished calculating Cluster Node version by Raphael Schitz, Freder
ic Martin v1.1
Attempted to divide by zero.
At C:\scripts\vCheck\Plugins\71 Capacity Planning.ps1:25 char:36
+ $VmCpuAverage = $CluCpuUsageAvg/ <<<< (Get-Cluster $cluv.name|Get
-VM).count
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
Attempted to divide by zero.
At C:\scripts\vCheck\Plugins\71 Capacity Planning.ps1:36 char:36
+ $VmMemAverage = $CluMemUsageAvg/ <<<< (Get-Cluster $cluv.name|Get
-VM).count
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
2:24:18 PM ..finished calculating QuickStats Capacity Planning by Raphael Schitz
, Frederic Martin v1.3
2:24:22 PM ..finished calculating Plugins not up to date or not installed by Ala
n Renouf, Jake Robinson, Frederic Martin v1.1
2:24:22 PM ..finished calculating Disconnecting from vCenter by Alan Renouf v1.1
2:24:22 PM ..Sending Email
*************************************************
Any ideas?
Thanks
Does anyone you know off anyway to get 1 vCheck to run against multiple VC’s in Linked mode rather than 1 for each VC? I have to set it up for 8 x VC’s which isn’t that big an effort but seems rather than having to receive 8 emails with 8 separate reports, it would be awesome to recieve a mega report so to speak.
@Lukas This is what worked for me…
Change $Filename to $ArchiveFilename in JUST the following to avoid the archive file from getting deleted at the end… you will find xxx.vcheck.xxx.htm stuff in your user->appdata->local->temp directory that failed to delete.
if ($Outputpath) {
$DateHTML = Get-Date -Format “yyyyMMddHH”
$ArchiveFilePath = $Outputpath + “\Archives\” + $VIServer
if (-not (Test-Path -PathType Container $ArchiveFilePath)) { New-Item $ArchiveFilePath -type directory | Out-Null }
$ArchiveFilename = $ArchiveFilePath + “\” + $VIServer + “_vCheck_” + $DateHTML + “.htm”
$MyReport | out-file -encoding ASCII -filepath $ArchiveFilename
}
Al, this behavior seems to happen when both outputpath is specified and attachment to e-mail.
I have a very strange problem. I think this started when I upgraded to PowerShell 3. In the snapshots section of the vCheck report the SizeMB column reports sizes with 20 decimal places. while I’m all for accuracy this seems like a little much. Any ideas on how to drop the decimal places and just show the whole number?
Nevermind I found where it goes. It goes in the 00 Connection Plugin for vCenter
NOT in the GlobalVariables. Hope this helps some other newbee like me!. Other
than that it is SLICK!
I put the $VIConnection = Connect-VIServer $VIServer –user “Administrator” –Pass “Johnb0” –Protocol Https on line 40 in the GlobalVariables.ps1 and it is still asking for a username and password. How do I automate it so I can just run the script and walk away without putting in anything extra
Can someone help explain the Snapshot Oversize portion? I understand the VM is the name, the vmdkSize is the size of the vmdk, the OverSize though I dont understand.
Alan this script is amazing, thank you for your hard work.
I love vCheck Thank you!! Could you add version reporting of vCenter itself? Down where you have host build verions, it would be nice to see vCenter version, VUM version, etc. Especially for those of us with multiple vCenter servers.
vCheck was incorrectly reporting the # of Datastore Clusters in my environment.
Looking at “01 General Information.ps1” we can see it calls out $(@($DatastoreClustersView).Count)
Unfortunately the collection for this variable is missing from “00 Connection Plugin for vCenter.ps1” To resolve, add the following code to the Connection Plugin:
Write-CustomOut “Collecting Detailed Datastore Cluster Objects”
$DatastoreClustersView = Get-DatastoreCluster | Sort Name
Hi there, when running the vCheck script, does it impact the environment? Will end users be impacted? That is, if running the script will it impact the HOST, Datastores and vCenter in general?
Is it possible to list the GUest via the “VM and Templates” child containers?
Is it also possible to show the Chain Linked-Clones, Lenght and revert points?
I am running Lab Manager 4 (and yes it dead) but until the company decides to move on. I need to generate a report
for all LabManager configuration showing Linked-Cloned, revert point and usage on the various datastores.
Thank,
Troy
@ayanes21 – You’re mixing versions of PowerCLI and vSphere / vCenter that aren’t totally compatible with each other. PowerCLI 5.1 is meant to be used with vSphere / vCenter 5.1. You need to use PowerCLI version 5.0 to work with vCenter 5.0. I’m not sure what the impact of vSphere 4.1 combined with vCenter 5.0 might be. It’s possible that you may need version 4.1 of PowerCLI for compatibility with vSphere 4.1.
Was wondering if there was something wrong with Plugin 60 – Powered Off VMs.ps1? Doesn’t seem to be generating the correct results.
For those intereseted in running against multiple vcenter servers.
Create a pre_vcheck.ps1 script with the code below, then comment out $Server in globalvariables.ps1.
$ServerList = “server1″,”server2″,”server3”
foreach ($server in $ServerList) {
.\vcheck.ps1 -$server -outputpath “\Output\”
}
@ Kevin Leek –
This may or may not help. It has helped me with powerCLI quite a bit with speeding things up. Here you go:
1. Start Internet Explorer
2. Go to the Tools menu
3. Go to Internet Options
4. Go to the Advanced tab and uncheck “Check for publisher’s certificate revocation” so there is no tick in the box.
Have a good day
first like everyone I want to thank you for this awesome script, however when I run it I get various errors as follows during run time, I am using ESX 4.1 update 2 with vcenter server 5.0 and PowerCLI 5.1. Also I am running this script from my Windows 7 workstation and it takes over 2 hours to complete I only have 8 hosts and about 120 VMs …
2:32:38 PM Collecting Detailed Alarm Objects
Get-View : Cannot validate argument on parameter ‘VIObject’. The argument is null or empty. Supply an argument that is not
null or empty and then try the command again.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins0 Connection Plugin for vCenter.ps1:92 char:21
+ $alarmMgr = get-view <<<< $serviceInstance.Content.alarmManager
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
I have checked the globalvariables.ps1 and it is pointing to my vcenter server by host name..
I also get these errors also
2:32:43 PM Collecting Detailed Datastore Objects
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins0 Connection Plugin for vCenter – Copy.ps1:101 char:70
+ $VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars <<<< (0)
+ CategoryInfo : InvalidOperation: (Chars:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
3:01:57 PM ..finished calculating Host Configuration Issues by Alan Renouf v1.1
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\36 Host Alarms.ps1:4 char:29
+ $alarms = $alarmMgr.GetAlarm <<<< ($null)
+ CategoryInfo : InvalidOperation: (GetAlarm:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
4:21:01 PM ..finished calculating Snapshot removed by Raphael Schitz, Frederic Martin v1.2
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not
null or empty and then try the command again.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:33 char:28
+ $dsb = Get-View <<<< (($ds | Get-View).Browser)
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Task <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : InvalidOperation: (SearchDatastoreSubFolders_Task:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMware.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : InvalidOperation: (WaitForTask:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not
null or empty and then try the command again.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:33 char:28
+ $dsb = Get-View <<<< (($ds | Get-View).Browser)
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Task <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : InvalidOperation: (SearchDatastoreSubFolders_Task:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMware.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : InvalidOperation: (WaitForTask:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not
null or empty and then try the command again.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:33 char:28
+ $dsb = Get-View <<<< (($ds | Get-View).Browser)
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Task <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : InvalidOperation: (SearchDatastoreSubFolders_Task:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMware.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : InvalidOperation: (WaitForTask:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is null or empty. Supply an argument that is not
null or empty and then try the command again.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:33 char:28
+ $dsb = Get-View <<<< (($ds | Get-View).Browser)
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Task <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : InvalidOperation: (SearchDatastoreSubFolders_Task:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\users\aapolinar\Documents\Admin Tools\vcheck\vmware\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMware.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : InvalidOperation: (WaitForTask:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
@Ethan Lowry,
to do multiple email addresses put this in the global variables like so:
$EmailTo =”example@example1.com”, “example@example2.com”
Great script – running this script on multiple VC’s seems to be a commonly requested feature. Adding multiple IP’s (seperated by a comma) doesn’t seem to be supported in the global vars.
Hello,
I have been using vCheck for a while and it is a great tool. I’m now running version 6 and would like to know if it is possible to output the results of the report to a .csv file.
Any help appreciated.
Hi,
I have the same issue as Hein (Sept 4). I have no before part in my globalvariables.ps1 so don’t know where to set my login details, any ideas?
Thanks for a great script.
Michael
I have the same problem Craig Wallace reported on 9/19/2012.
How do I filter out snapshots created by our backup software??
How do I enable using ‘VMs and Network Settings’ plugin??
Thank you, Tom
The setting change to have get multiple email recipients of the report doesn’t seem to function for me. I have tried all kinds of combinations without success (including the one posted in at the end of the vCheck page). Has anyone been able to get this to work?
Hi all,
Speed question. I have had vCheck running on a separate server from our vCenter server. Our vCenter server also hosts SQL.2008 on the same physical box.
It was running 20-25 minutes every night beautifully.
Then we migrated SQL/vCenter onto newer, faster hardware. Now, vCheck takes 120+ minutes every night.
The new server hardware is using the same network cable and switch port as the old box, all drivers/firmware have been updated, and traditional network speed checks (file copy, etc) all check out good.
So I assume there is something in the SQL/vCenter installation and/or configuration that is different and slowing it down compared to before. All the basic settings seem to be the same.
Any suggestions on why it would be 5-10x slower on a new, faster box?
Hi, the -outputpath does not work for me. It only creates the folders D:\vCheck\Archives\VI-Servername, but there is no file. Also no error. The directory were created automatically, so it should not be an ntfs-right-issue.
Does this script work for monitoring a standalone ESXi 5 server and NOT connected to a vcenter server? thanks
All. I have in my settings $DisplaytoScreen =$false but when running the script it is still opening up in IE
Any ideas?
hello,where i can download v5.1 which have fixed the displaying issue with outlook2007/2010?
Hello.
Thanks for an amazing script. Quick question, i have multiple vCenter servers and would love to have them all report in one email. is this possible?
Thanks for the excellent reporting tool!!
I run Two vCenters both have a common user, is there a way to add in a second vCenter so I can run a single report on both?
I’ve noticed that in situations where vCheck runs for hours that using some of the data collected at the beginning of vCheck will be stale and cause erroneous results. These results will cause me to look at reported issues that are not valid. I suggest that a timestamp be stored with information on when particular data was collected so that the plug-ins can make intelligent decisions based on this timestamp whether to freshen the data or continue using it as is.
Can someone please help me in solving the below error
PS C:\Pearl script> .\vCheck.ps1
File C:\Pearl script\vCheck.ps1 cannot be loaded. The file C:\Pearl script\vChe
ck.ps1 is not digitally signed. The script will not execute on the system. Plea
se see “get-help about_signing” for more details..
At line:1 char:13
+ .\vCheck.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
If we go to change the globalvariables file to add the account name and pass for the vcenter server we don’t see the Before part:
Before
1 $VIConnection = Connect-VIServer $VIServer
After
1 $VIConnection = Connect-VIServer $VIServer –user “AlternateUsername” –Pass “Alternatepassword” –Protocol Https
And even if we enter the new rule powershell says the connect-viserver function is not recognised. Are we missing something?
FYI: The variable $limitSnapshotOversizeShow is not defined. I just add it in “64 Snapshots Oversize.ps1” with a value 120.
i would luv to an answer file rather waiting for & typing the command.
I’m stuck after
…finished calculating VM CPU %RDY
pls help
Awesome script Al. Hoping to say thanks in person at VMworld.
We have a few Fault Tolerant VM’s, and they often come up in the report for:
27 VM Tools Issues.ps1
19 Guests with less than X MB free.ps1
22 Checking VM Hardware Version.ps1
Sometimes they will be listed twice (i’m guessing primary & secondary VM), or listed once with no data.
Is there a forum for this, or just keep using the comments? VMTN perhaps.
I’m also missing the creator on the snapshot information section. Mainly noticed the issue when attachment is true.
Secondary question is someone aware of an Active Directory or SQL script similar or based on vCheck?
I have duplicate entries in my report. I must of messed something up. Anyone know what would cause everything to be reported twice?
I want to change turn some of these checks into functions so I can load them in my powershell profile. This would be very useful as they can act as extensions to powercli…for example get-generalinfo or get-vmhostdeadluns for APD cases and so on….so what would be the easiest way to achieving this.
Is there a one liner or something I can incorporate into a small script that woudl show:
“Machine name: blah blah” was shut off at such and such time by such and such person” then email that alert? I know there is a “who deleted my vm script that is similar:
I am using version 5 at the moment and its great however having issues running version 6. How do I save a script that uses seperate credentials then my own? This was possible in version 5 but in version 6 the login method is different now.
I have 2 questions / Issues.
1 – What is the easiest way to exclude multiple account names from the snapshots Created?
2 – For some reason I am still not getting creator on the snapshot information plugin, any thoughts ?
Hi Al,
In our environment we run backups every night, how can i can get the snapshot plugin to ignore all the snapshots created by Netbackup and report on snapshots created by all other users.
Great Script, Cheers Steve
script runs fine, but the event logs only return info on what couldn;t be scanned, whereas the old version Error Events gave login failures etc….
can i get that info from vCheck 6?
Then I am sadly out of ideas. It worked for me but I don’t do enough scripting to see where I may have made any mistakes. If you figure it out, please let me know
@Dave
Thanks for the pointer for that plugin. I made the changes to the plugin but it’s still pulling all the warning messages. This is a great start and I’m going to have to scratch my head over this a little bit.
Pat
…also just figured out, I got the variables the wrong way round in that code DOH!
BTW I figured out as the snapshot account was just matching any part of the string, just omitting the domain name corrected that issue, but I am still looking for reasons for the “Swapfile not set” issue if anyone can help at all…
@Pat
I am not the best powershell user in the world so I make no claims to this being the best or most efficient way to do this but I noticed the same issue and made the following changes to plugin 44 and it seems to work for me. As the messages are text only, I don’t know if there is a way of looking for the past 24 hours, but instead I list those messages with todays or yesterdays date.
If anyone can do this better, please tell me how… This is a learning experience as far as I’m concerned…
...
...
...
foreach ($VMHost in ($HostsViews)){
#
# Dave - Additional variables for dates
#
$yesterday = (Get-Date -displayhint date -format "yyyy-MM-dd")
$today = (Get-Date -date ((Get-Date).AddDays(-1)) -displayhint date -format "yyyy-MM-dd")
#
# Dave - End additional variables for dates
#
$product = $VMHost.config.product.ProductLineId
if ($product -eq "embeddedEsx" -and $VIVersion -lt 5){
# Original $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$_ -match "warning" -and $_ -match "vmkernel"}
$Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$_ -match "warning" -and $_ -match "vmkernel" -and ($_ -match $yesterday -or $_ -match $today)}
if ($Warnings -ne $null) {
...
...
...
else
{
# Original $Warnings = (Get-Log –VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning"}
$Warnings = (Get-Log –VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning" -and ($_ -match $yesterday -or $_ -match $today)}
if ($Warnings -ne $null) {
...
...
...
This script is awesome and saves me so much time!
I have recently been modifying parts of the script to use this more as an initial evaluation tool rather than an ongoing maintenance check and have encountered an issue with the “Guest with less than X MB Free” plugin. I would like this plugin to report on all guest disks and provide an output that includes GB of allocated disk space, GB of free disk space, and percentage of free space.
I have worked out the first two but am having an issue with the percentage output as well as this generates a line for every guest disk on a VM so for example, if a VM has 5 guest disks there are 5 lines with the exact same info generated. Here is the current content of the plugin:
# Start of Settings
# VM Disk space left, set the amount you would like to report on
$MBFree =10000240
# End of Settings
$MyCollection = @()
$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq “poweredOn” -And ($_.Guest.toolsStatus -ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne “toolsNotRunning”)}
$SortedVMs = $AllVMs | Select *, @{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
ForEach ($VMdsk in $SortedVMs){
$Details = New-object PSObject
$DiskNum = 0
$Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty
Foreach ($disk in $VMdsk.Guest.Disk){
if (([math]::Round($disk.FreeSpace / 1GB)) -lt $MBFree){
$Details | Add-Member -Name “Disk$($DiskNum)” -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name “Disk$DiskNum Capacity(GB)” -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1GB))
$Details | Add-Member -Name “Disk$DiskNum FreeSpace(GB)” -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1GB))
$DiskNum++
$MyCollection += $Details
}
}
}
$MyCollection
If someone could assist me in adding the percentage output and removing the duplicate entries when guests have multiple disks it would be very appreciated!
Thanks again I hope everyone keeps up the great work with this framework!
-Lance
I have poed over your site and have found so much good info for a newb at this like I am but I just cannot find the solution to my issue. I have your script vcheck 5.0 and powershell 2.o and PowerCLI 5.0 on 2 different farms. One works great, only thing missing from the report is the vm cpu/memuseage max/average. One on the other farm I continue to get the “The Connect-VISERVER Cmdlet did not work, please check you VI Server. ” message emailed to me. I have tried everything I have found on this site but it continues. Even tried starting from scratch with same raw script used on both farms. Would appreciate any help given. Thanks for all the work on these scripts huge timesaver!!!
Hi Alan, I need your help. The reports runs fine through schedule task but i am unable to get an email in my mailbox. i am able to telnet my smtp server.
Any idea ?
Hi Alan,
What a great script, thank you very much for making it available! I have one question though if you have the time.
I am running the script on a vCenter that has vCloud connected to it and in the reports for VMware tools I get a list of all the vSheild edge devices. is there a way to exclude any VM with a name beginning with “vse-“. I am a novice PowerCLI user and could not see how to do it in your script.
All the best!
Hi Alan,
THANKS to you and everyone for all the great work. I love version 6! But I’m having an issue with the VMKernel Warnings plugin. It pulls ALL the warnings from my log files no matter how old they are.
I’m running vSphere 5 with ESXi 5 hosts so it looks like the script just pull everything that matches “warning”. Is there an easy way to add a date range so it only gets the last X days?
Thanks again!
Hi Alan,
Did you removed capacity planner in 6.15 version ????. It was available in V5?
instead manual entry, can we automate the process?
Guys
What is the syntax used to exclude virtual machines from vcheck?
I would like to exclude a handful of machines from the check, appears a few people have asked this question but i dont see an answer?
Awesome script btw
cheers
A few mods that I’ve made because I have multiple datacenters with the same cluster names and datastores with the same name…
56 Clusters with HA Disabled.ps1: I need to know which datacenter it is in, so this will show the parent of the cluster.
$Result = @( $Clusters | Where-Object {-not $_.HAEnabled} | Select-Object -Property Name,@{Label=’Datacenter’;Expression={$_.ParentFolder.Parent.Name}},HAEnabled)
03 Datastore Information.ps1: Added datacenter and datastore type to the output.
$OutputDatastores = @($Datastores | Select Name, Datacenter, Type, @{N=”CapacityGB”;E={[math]::Round($_.CapacityGB,2)}}, @{N=”FreeSpaceGB”;E={[math]::Round($_.FreeSpaceGB,2)}}, PercentFree| Sort PercentFree)| Where { $_.PercentFree -lt $DatastoreSpace }
@l8nighter: Use this syntax for assigning the $EmailTo instead.
[string[]] $EmailTo = “yourName@yourDomain.com”, “hisName@hisDomain.com”
Rick
I love the script. We were using version V2 and are currently upgrading to Vcenter 5 so I decided to check for a new version. New scripts are sweet except I can’t seem to get some of them to display. It runs with no erros but Im missing a few plugins that don’t show up in the report for example the datastore information… Do items only show up in the report if they have at least 1 vm or item matching the cirtera ?
Thanks again
Ok. I have done some digging of my own and found that the reason none of the VM’s that I know have CDROM’s configured is that the are not
connected! This still has the effect that they can not be vMotioned. vCenter complains because they are host based (vmtools mounts, etc)
Searching the web I found a few other ways of checking if a CDROm is configured (not just attached). The command I found worked the best was:
$Result = @($VM | where {$_.cddrives | %{$_.IsoPath -ne $null}} | Select Name, VMHost)
It still has issues. I’m a complete novive with powercli/powershell so I have no idea how I can rewrite this to fix the problem with the cddrives property. (Its obselete and I should use Get-CDDrive instead but its not a direct replacement 🙁 )
It also reports a system if it has more than one CDRom even if both are configured asd client devices.
I would like it to include the details of the mounted cdrom path but the code I found gives strange results in the report.
Using ft name,host,@{label=”ISOPath”; Expr = { ($_ | get-cddrive).ISOPath } } instead of Select Name, VMHost
This works from powershell directly but in the plugin.
Any suggestions?
Hi,
basically, this is the same question as already posted by bwuch (May 14, 2011 at 13:13), but I didn’t find an answer yet.
We have two vCenters running in linked mode.
When running the vCheck script towards the first vCenter only this vCenter is polled. Is it possible to configure several vCenters in the GlobalVariables part?
DefaultServerMode is set to multiple.
If possible, I want to have all information in one report.
Thanks,
Sebastian
One more thought, It would also be nice for checking if there was an otion to list all the VM’s that will be checked at the beginnign of the scripts. Again enabled as a variable, possibly as part of Plugin 01.
Hi,
Im running vCheck 6.15 under powerCLI 5.0.1. on windows 2008 against vcenter 5 (not update 1).
I am seeing some odd behaviour. When running the script will all plugins, plugin 28 returns no results.
If I run the script with plugins 00, 01, 28, Plugins not up to date…, and VerylastPlugin…, I get results from the first cluster only.
My first question is, Is it possible to get the script to include the title of the plugin and say “No Problems found” rather than not including it in the report. That way I can see that the test has actually be run. It would be nice if this was an option variable along with the email options etc.
Secondly, Why does the CD Roms conected plugin only check the first cluster when running as the only plugin and does not seem to run in combination with all the other checks? How can I fix this?
..oops, the brackets around my vcenter name made the name disappear from my previous post…
It should read:
./vCheck5.ps1 vcenter01
./vCheck5.ps1 vcenter02
..
Wonderful script Alan, so many thanks..
In version vCheck5 I am used to run the script against 4 vCenters with a command line like:
./vCheck5.ps1
./vCheck5.ps1
..
Will this option be available again in vCheck 6.xx?
I’ve just built a new Win-7 VM so that I could upgrade to the new version of vCheck. It’s GREAT! Thanks to everyone for all the work that has gone into it.
There’s only one problem that I’m having. When I run the script, there are 3 plugins (“41 vCenter Services.ps1”, “42 Windows vCenter Error Event Logs.ps1”, and “43 Windows vCenter Warning Event Logs.ps1” which give me the following error: Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA). I’ve checked my services and everything appears to be running OK.
Any ideas?
THANKS again!
Pat
“I am getting ‘Swapfile location NOT SET’ on all our hosts. I have checked, double checked, and even unset/reset the datastore, but it doesn’t seem to report right. Is this something I am doing wrong?
…also, are there special characters that cannot be used as part of user exemptions (snapshots created and removed plugins). Our SAN creates and removes snapshots based on a domain account which contains a ‘\’ and a ‘.’ and while the header shows the right username as exempt, there are still dozens of snapshots listed with the same account details.”
Any comments on these couple of issues please, esp the snapshot one. I am taking 2-hourly snapshots via the SAN which is creating pages and pages of report to scan through to make sure our users are not creating their own manually.
Also… a couple of suggestions for an already great tool (no idea how much it would take to implement as I am not much of a powershell user). Firstly, is it possible to add an exceptions list, in its simplest form containing objects to omit from any results. We have standards for our own servers which I can report for anything outside these standards, but also we have third party VMs out of our control which I cannot do anything about. Secondly, is it possible to have a warning and critical threshold, perhaps colour coded on the report, for items that warrent it (like datastore free space etc).
Great pack guys, thank you for the vCheck. It’s on completely different level from my own scripts 🙂 There is a lot of thinks, that I don’t even think about. Thanks again.
Hi, i saw a post asking how to add a report that showing orphaned vmdk intu the report. I was looking that also and found in the vmware.com communitythat LucD write a PCLI script to show the orphaned vmdk list.
Here is the code I was modified and save it in plugins folder of vCheck as XX Orphaned VMDK.ps1.
# Start of Settings
# End of Settings
$report = @()
$arrUsedDisks = Get-View -ViewType VirtualMachine | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile}
$arrDS = $Datastores | Sort-Object -property Name
foreach ($strDatastore in $arrDS) {
$ds = Get-Datastore -Name $strDatastore.Name | % {Get-View $_.Id}
$fileQueryFlags = New-Object VMware.Vim.FileQueryFlags
$fileQueryFlags.FileSize = $true
$fileQueryFlags.FileType = $true
$fileQueryFlags.Modification = $true
$searchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec
$searchSpec.details = $fileQueryFlags
$searchSpec.matchPattern = “*.vmdk”
$searchSpec.sortFoldersFirst = $true
$dsBrowser = Get-View $ds.browser
$rootPath = “[” + $ds.Name + “]”
$searchResult = $dsBrowser.SearchDatastoreSubFolders($rootPath, $searchSpec)
foreach ($folder in $searchResult)
{
foreach ($fileResult in $folder.File)
{
if ($fileResult.Path)
{
if (-not ($arrUsedDisks -contains ($folder.FolderPath + $fileResult.Path)))
{
$row = “” | Select DS, Path, File, Size, ModDate
$row.DS = $strDatastore.Name
$row.Path = $folder.FolderPath
$row.File = $fileResult.Path
$row.Size = $fileResult.FileSize
$row.ModDate = $fileResult.Modification
$report += $row
}
}
}
}
}
$report
$Title = “Orphaned VMDK(s) Information”
$Header = “Orphaned VMDK(s) Information”
$Comments = “Orphaned VMDK(s) details on the Development infrastructure”
$Display = “Table”
$Author = “LucD”
$PluginVersion = 1.0
$PluginCategory = “vSphere”
We have three virtual centers in our environment and i am running the report on all three from three different folders at 5am in the morning. All three get stuck at VC Services, Windows vCenter Error Event Logs and Windows vCenter Warning Event Logs plugins… any ideas? It
I need to be able to send the vCheck email to multiple email address so I followed the FAQ above and changed it to $EmailTo ="user01@example.com", "user02@example.com"
But when I run it gives me the following error:
Ampersand not allowed. The & operator is reserved for future use; use “&” to pass ampersand as a string.
It looks like “16 Host Swapfile datastores.ps1” should be checking for the absence of a value instead of checking for a value. I’m getting a list of all of my ESX hosts and I verified that they have a swap datastore set yet this plug-in produces output of “Swapfile location NOT SET”.
br_nar says:
May 24, 2012 at 06:17
@noob: did you install PowerCLI v5.0.1?
no, version 4. I installed 5 but no luck ….
Hi Ron,
I don’t use Hyper-V at work or home but stumbled across this searching for ways to distinguish VMWare vm’s from Physical machines:
Their script looks for services for either VMWare or Hyper-V. Are you looking to query for the hypervisor itself or the guest OS that is virtual?
I really wish Microsoft would just put an attribute on the computer object in AD: “Virtual” and a value of either True or False. It would make life so much easier right now. I guess we could always create our own custom attribute and extend the AD schema but I’m afraid of screwing up my Production Network by customizing that.
While we’re on the topic of querying AD Computer Objects, was wondering if one of your scripts (Alan or Andrew) could isolate or distinguish any Hyper-V Servers that might exist in the environment as well.
Not sure how to accomplish this but what I do know is that the results of the command Get-Windows Feature is supposed to list what features and roles are available, and what their install status is (indicated by an X) on Windows Platforms. Since Hyper-V is installed as a Role in Server Manager this may be key to isolating its presence.
Any help would be appreciated. Thx
Andrew,
I have been sent a couple of AD scripts recently, I need to add these to my site, would be great to add yours to them if it covers areas they dont.
Hopefully I will add these over the next couple of days.
Alan
For some reason my management at work is harping on virtualization. We virtualized almost all of our physical servers over to ESXi 4.1 on Cisco USC Blades about a year ago. Manager wants a count of Servers by OS that are physical and virtualized and then total % virtualized. i.e. something like this:
OS Virtual Physical
Server 2003 1 5
Server 2008 5 1
Server 2008 R2 22 2
————————————————————————————
36 Total Servers in Domain blah. 28 /36 (x%) Virtualized
I’m struggling with what is the most efficient/accurate way of getting this info.
Option A. Get-ADComputers where OS is like *server*. Ping list. If Ping = True then wmi query for Manufacturer or model as VMWare will write “VMWare, Inc” or something similar in those fields. Count Mfg/Model. Output to column. Else Model value is not “VMWare, Inc” therefore physical machine. Get total count of both physical and virtual. Divide to get % virtualized.
Cons: Stale computer objects in AD. Machines not pingable, Machines powered off.
Option B. Query AD for ADComputers where OS is like *server*. Ping list. If Ping then query for services -like “*VM*”. If service is found then its a virtual machine, Else its physical.
Cons: If you query for VM Tools Service and someone forgot to install VM Tools then output isn’t accurate. Stale computer objects in AD. Machines not pingable due to network config, Machines powered off.
Option C. Get count of all Server OS from AD (this will include all servers; virtual and physical). Get count of VM Servers using VMWare CLI\vcheck. subtract VM Count from AD Count and whatever is leftover is physical.
Cons: Stale AD Computer Objects in AD. Inactive VM’s on VSphere.
Option D. If we had standardized hostnames, I could query that from AD (ie. vServer1, vServer2, pServer3). Unfortunately, previous admins created hostnames on a whim with no consistency what-so-ever. So this is out of the question until we standardize.
Which route to take? I realize that the output probably will never be 100% accurate but if I can get it to 90%+ then I would be happy. Am I over-complicating this? Any advice is greatly appreciated.
I love this Framework! Thanks for creating and posting. I wrote my own weekly plugins for Active Directory (stuff like count of computers by OS, Expired Accounts, Passwords set to never expire,Orphaned Home Dir’s and Profiles, Users/Computers created last 7 days, etc etc etc) using this framework.
Alan, I’m more than willing to share what I put together for AD but I’m a novice Powershell scripter at best. My scripting methods probably aren’t the most efficient in terms of execution time and can probably be cleaned up if you are willing.
Chad posted about a NetApp vcheck. Is this posted anywhere yet? Also interested in a SQL/WebDev daily script if anyone has started that.
I rely on the daily reports I receive from vCheck and think it’s great.
One thing I am trying to work around though relates to plugin 44 VMKernel Warnings. I see a whole bunch of items there for all dates. I would much rather see just the items just from the previous day (since I have it running each day).
I saw in the release notes “# v 6.9 – Fixed VMKernel logs but had to remove date/Time parser due to inconsistent VMKernel Log entries” I started with v6.15 so not sure what behaviour this specifically refers to but sounds like there used to be a date/time filter on the results shown, and then it was removed.
Is it possible to restrict the included items? Is there a way to acknowledge those types of alerts so only new ones are included?
Thanks
-Randy-
Would it be possible to exempt entries from appearing on plugin “53 Hardware status warnings-errors”?
the report keeps tripping on “Battery on Controller 0 Charging …” messages which are normal behavior.
thanks.
When I run the script I get about a dozen errors when it starts processing plugin 02, the snapshot plugin.
The error is:
Get-View : 5/24/2012 8:30:19 AM Get-View View with Id ‘VirtualMachin
e-vm-1909’ was not found on the server(s).
At C:\scripts\Plugins2 Snapshot Information.ps1:88 char:18
+ $vm = Get-View <<<< $_.Entity
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutoma
tion.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Where does the view come from? We do not have any VMs that use the naming convention in the error messages. As I mentioned, I get about a dozen of these over about a 30 minute time span and then the script runs to completion fairly quickly.
@noob: did you install PowerCLI v5.0.1?
thanks for a great script !
i have 1 problem …. i get “System.OutOfMemoryException” errors.
2:58:48 PM Adding Custom properties
2:58:48 PM Collecting VM Objects
3:00:13 PM Collecting VM Host Objects
3:01:39 PM Collecting Cluster Objects
3:01:41 PM Collecting Datastore Objects
3:01:44 PM Collecting Detailed VM Objects
3:07:17 PM Collecting Template Objects
3:07:56 PM Collecting Detailed VI Objects
3:07:57 PM Collecting Detailed Alarm Objects
3:07:57 PM Collecting Detailed VMHost Objects
Get-View : 5/21/2012 3:18:26 PM Get-View Exception of type ‘System.OutOfMemoryException’ was thrown.
At C:\ESX scripts\vCheck – xxxxVC03\GlobalVariables.ps1:87 char:23
+ $HostsViews = Get-View <<<< -ViewType hostsystem
+ CategoryInfo : NotSpecified: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.
GetVIView
Can someone help me understand how to solve this please ?
Hi Alan,
I have been working on creating a Hyper V flavor of vCheck using your HTML template and plugin structure. I would love to make this available to the community and would appreciate it if you could get in touch.
Kind Regards,
Ross Worth
Hi All,
When i run the report, for plugin 71 (Capacity Planning) I get the following error:
Get-Cluster : 18/05/2012 11:12:57 Get-Cluster Cluster with name ‘HA%2fDRS Cluster’ was not found, using the s
pecified filter(s).
At C:\scripts\vCheck\Plugins\71 Capacity Planning.ps1:19 char:28
+ $cluvmlist = (Get-Cluster <<<< $cluv.name|Get-VM)
+ CategoryInfo : ObjectNotFound: (:) [Get-Cluster], VimException
+ FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetClu
ster
And the report does not show any statistics under Estimated Num VM Left (CPU) etc.
—–
I am also having an issue with plugin 44 VMKernel Warnings.ps1. I have set my remote signed to unrestricted however it keeps coming up with
"Security Warning
Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your
computer. Do you want to run C:\scripts\vCheck\Plugins\44 VMKernel Warnings.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"):"
Any help would be greatly appreciated.
Thank you
Any help would be greatly appreciated.
Hi Alan,
Any progress on the NetApp-filer plugin?
Nevermind about the plugin option vs globalvariables option. As I think more, you would want to be able to set other different parameters (like email address, subject, etc…). I will try to rework my changes to allow that choice instead. Thanks for everything!
Love the script!!!
I am extremely new to powershell in general and had one advice question. I added an extra param to the script to set a different plugins path. I am hoping that I can have different setups for different scheduled emails. Like one general stats set for the bosses, an error one for us folks in the trenches, etc… Do you think it would be more beneficial to do it that way or to have the plugins path in the GlobalVariables and make the GlobalVariables filename/path be an optional param?
Thanks for your help to me and the community in general!!!
I’ve been running a previous version for sometime. I run the script against several different vCenters. With the new setup of the script is there still a way to keep certain settings static and then feed parameters to the script for the different vCenters names? Or would I need to make a directory for each vc so that each has its own script and global variables file? Or is there a way to have a global variable file for each vc and feed that to the initial launch of the vcheck script?
Forgot to mention, one of the errors is from a plug in in the comments and not one included with vCheck.
VMs by Operating System by Your Name v1.1
http://www.virtu-al.net/featured-scripts/vcheck/vcheck-plugins/#comment-14329
I’m trying out v6.15 against a v5 Update 1 vcenter and v5 Update ESXi hosts. Right now I have hte account I use for vCheck set with Admin privilidges but I’ll eventually dop that down to the lowest level needed. Teh account has non-porpogated rights at the top level, the propogated on a particular cluster and on the associated datastores. I’m see a few errors and I’m not sure if they are benign or will affect the related plugin.
Errors, full run all included plug-ins enabled:
You cannot call a method on a null-valued expression.
At C:\vCheck\Plugins\25 VMs in inconsistent folders.ps1:7 char:69
+ $Folder = ((($CHKVM.Summary.Config.VmPathName).Split(‘]’)[1]).Split <<<<
('/'))[0].TrimStart(' ')
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
11:24:38 AM ..finished calculating VMs in inconsistent folders by Alan Renouf v1.1
Get-VMResourceConfiguration : 4/30/2012 11:45:26 AM Get-VMResourceConfiguration
Object reference not set to an instance of an object.
At C:\vCheck\Plugins\50 VMs with CPU or Memory Limits Configured.ps1:10 char:36
+ @($VM | Get-VMResourceConfiguration <<<< | Where-Object {$_.CpuLimitMHZ -ne
'-1' -or $_.MemLimitMB -ne `-1`} | Select-Object VM,CpuLimitMhz,MemLimitMB)
+ CategoryInfo : NotSpecified: (:) [Get-VMResourceConfiguration],
VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.GetVMResourceConfiguration
11:45:36 AM ..finished calculating VMs with CPU or Memory Limits Configured by Jonathan Medd v1.1
Get-View : 4/30/2012 11:47:10 AM Get-View
At C:\vCheck\Plugins\61 Guest OS Version.ps1:12 char:16
+ $VM | Get-View <<<< | % {
+ CategoryInfo : NotSpecified: (:) [Get-View], NoPermission
+ FullyQualifiedErrorId : Client20_MoServiceImpl_GetNetInteropView_ViError
,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
11:47:28 AM ..finished calculating VMs by Operating System by Your Name v1.1
You cannot call a method on a null-valued expression.
At C:\vCheck\Plugins\62 Unwanted virtual hardware.ps1:9 char:53
+ $vmguest.Config.Hardware.Device | where {$_.GetType <<<< ().Name -match $
unwantedHardware} | %{
+ CategoryInfo : InvalidOperation: (GetType:String) [], RuntimeEx
ception
+ FullyQualifiedErrorId : InvokeMethodOnNull
11:47:29 AM ..finished calculating Unwanted virtual hardware found by Frederic Martin v1.1
Thanks!
It actually finished and has a lot of great info. It took 30 minutes to finish. Great script.
Alan,
Cool script. I am running against a vCenter 4.1U2 system with ESX 4.1U2 hosts. My workststion is Win7. The vCenter server is Win2008. Whether I run the CLI from the vCenter server itself or from my workstation I am getting the following result:
7:27:06 AM Connecting to VI Server
7:27:18 AM Adding Custom properties
7:27:18 AM Collecting VM Objects
7:27:28 AM Collecting VM Host Objects
7:27:30 AM Collecting Cluster Objects
7:27:30 AM Collecting Datastore Objects
7:27:30 AM Collecting Detailed VM Objects
7:27:35 AM Collecting Template Objects
7:27:36 AM Collecting Detailed VI Objects
7:27:36 AM Collecting Detailed Alarm Objects
7:27:36 AM Collecting Detailed VMHost Objects
7:27:42 AM Collecting Detailed Cluster Objects
7:27:42 AM Collecting Detailed Datastore Objects
7:27:42 AM ..finished calculating Connection settings for vCenter by Alan Renouf v1.3
7:27:42 AM ..finished calculating General Information by Alan Renouf, Frederic Martin v1.1
Get-View : 4/25/2012 7:30:43 AM Get-View View with Id ‘VirtualMachine-vm-1909’ was not found on the server(s).
At C:\scripts\Plugins2 Snapshot Information.ps1:88 char:18
+ $vm = Get-View <<<< $_.Entity
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Get-View : 4/25/2012 7:30:43 AM Get-View View with Id 'VirtualMachine-vm-1909' was not found on the server(s).
At C:\scripts\Plugins2 Snapshot Information.ps1:88 char:18
+ $vm = Get-View <<<< $_.Entity
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Get-View : 4/25/2012 7:31:16 AM Get-View View with Id 'VirtualMachine-vm-5259' was not found on the server(s).
At C:\scripts\Plugins2 Snapshot Information.ps1:88 char:18
+ $vm = Get-View <<<< $_.Entity
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Get-View : 4/25/2012 7:31:20 AM Get-View View with Id 'VirtualMachine-vm-1905' was not found on the server(s).
At C:\scripts\Plugins2 Snapshot Information.ps1:88 char:18
+ $vm = Get-View <<<< $_.Entity
+ CategoryInfo : ObjectNotFound: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_GetView_WriteNotFoundError,VMware.VimAutomation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Same error either way. I am not getting a login prompt for the server at all. I am logged onto my workstation with the same account that is the master admin of the vCenter and is in the Admin group on bothe systems. The VM names listed are not our naming config. Any pointers on where the error may be?
Pingback: vCheck for Exchange | Lord PowerShell
I am getting ‘Swapfile location NOT SET’ on all our hosts. I have checked, double checked, and even unset/reset the datastore, but it doesn’t seem to report right. Is this something I am doing wrong?
…also, are there special characters that cannot be used as part of user exemptions (snapshots created and removed plugins). Our SAN creates and removes snapshots based on a domain account which contains a ‘\’ and a ‘.’ and while the header shows the right username as exempt, there are still dozens of snapshots listed with the same account details.
Love the tool though, and especially the new format with v6. It’s made my life a lot easier! Thank you!
@Chad, I would be very interested to see what you have done with the NetApp plugin too…
Hi Al,
Great script, absolutely amazing, a couple of things i would like to ask about though are with snapshots. How can i stop it from detailing snapshots created and removed by VCB, and also how can i configure it to identify orphaned snapshots.
Hi Alan;
My PowerShell scripting sucks. I’m hoping to generate a Report that lists the Primary Nodes of all Clusters. I can run the PowerCLI manually but can’t seem to run it thru vCheck.
This is the gist of what I’m trying to achieve:
$_.HAEnabled -eq $true
Get-HAPrimaryVMHost
Select Name, Parent
Sort by Cluster Name
We’ve been having HA issues recently in our Blade environment. Troubleshooting this was a pain but results revealed the Primary HA Node (or “fail-over Coordinator” ) had gone offline. Unfortunately, the promotion of a Secondary Host failed to occur before the Host went offline… This had negative effects on HA functionality of the Cluster as a whole.
Any help, by anyone, would be appreciated.
Thx
Hi Chad,
I’m very interested in your script for the NetApp filers! I’ll keep track on Alan whenever he releases them.
Chad,
Awesome! Make sure you send it over to ajw.renouf@googlmail.com for me to check it out, would love to see a sample and create a post on these.
BTW, I too use Gmail for my email and had to do the same thing 😉
I altered the GlobalVariables.ps1 and vCheck.ps1 to allow for one to use Gmail as their outgoing mail server. We use Google Apps for email and I had to allow for SSL encryption and an alternate port for sending email. I added some variables to GlobalVariables.ps1 so that it could be configured during the setup and then changed the email function around a little in vCheck.ps1 to allow for the new settings. I could upload the code changes if anyone is interested.
I also just finished a NetApp plugin which will report on the status of your Netapp filers, report on any volumes over X% utilization, and also report on any snapshots older than X days and larger than X MB. I can upload these as well, but not sure how to do so at the moment.
Line 23 of 01 General Information reads
$VIVersion -ge 5 shouldn’t this be $VIVersion -ge “5” I’m only running VI 4.1 and the system keep checking for the vSphere 5 info.
Hi Alan,
First of all, thank you for vCheck. It’s very usefull.
We got a little issue when we sent the report in HTML mail : the header (the picture) is not display and the results of some plugins (typicaly the first and the last) appears in Time new roman and not in Tahoma. If we display the result in a web browser all is alright.
Have you any idea to resolve our issue ?
Thank in advance and keep going on !
Seb.
Thanks for the great work guys.
Is there any way to get the script to interrogate more than one vCenter server?
In GlobalVariables.ps1 i can see the variable $Server being called.
How do i assign it more than one vCenter server?
Pingback: Manipulation de snapshots » vg5000.org
first – let me thank you vCheck – it saved me a lot of work!
i found the plugins xml file on the website is not updated – all links are getting 404
http://www.virtu-al.net/vcheck/plugins/plugins.xml
i believe it should be updated to reflect the correct path.
Ofer
Pingback: Segregating The vCheck Daily Report Scripts - Chris Colotti's Blog
Is there any way to determine (via Plugin) which VMs may be using Raw Device Mappings?
Thx
Hi I’m getting the following error when called within the script but do not get this error when I run the cmdlet on its own. Any clues?
Get-View : 2012-04-03 13:02:50 PM Get-View Exception of type ‘System.
OutOfMemoryException’ was thrown.
At C:\vcheck6.15\Plugins0 Connection Plugin for vCenter.ps1:94 char:23
+ $HostsViews = Get-View <<<< -ViewType hostsystem
+ CategoryInfo : NotSpecified: (:) [Get-View], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Guys
When running this after the initial config i get the following error and i keep getting the credentials prompt, anyone got any ideas? I am trying to automate this but during the scheduled task it stops here waiting for me to enter username and password.
ConvertTo-SecureString : Key not valid for use in specified state.
At C:\Scripts\vCheck\vCheckVMWare\xxxxxxxxxxxx\Plugins\41 vCenter Services.ps1:6
char:145
+ $creds = New-Object System.Management.Automation.PsCredential($LoadedCred
entials.Username,($LoadedCredentials.Password | ConvertTo-SecureString <<<< ))
+ CategoryInfo : InvalidArgument: (:) [ConvertTo-SecureString], C
ryptographicException
+ FullyQualifiedErrorId : ImportSecureString_InvalidArgument_Cryptographic
Error,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand
New-Object : Exception calling ".ctor" with "2" argument(s): "Cannot process ar
gument because the value of argument "password" is null. Change the value of ar
gument "password" to a non-null value."
At C:\Scripts\vCheck\vCheckVMWare\xxxxxxxxxxxx\Plugins\41 vCenter Services.ps1:6
char:21
+ $creds = New-Object <<<< System.Management.Automation.PsCredential($Load
edCredentials.Username,($LoadedCredentials.Password | ConvertTo-SecureString))
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
07:04:01 ..finished calculating VC Services by Alan Renouf v1.1
Greg, You need to schedule it as a Windows Scheduled task, you can then define when it runs and when you receive the email.
How do I find out when the vCheck script will be run and when I will get the generated email? Does it generate an email every time it runs? If so, I never got an email on the initial run of the script.
In plugin “00 Connection Plugin for vCenter.ps1″ the line
$Report.Name = $_.Name”
in the functions Get-VMLastPoweredOffDate and
Get-VMLastPoweredOnDate should be changed into:
$Report.Name = $vm.Name
Otherwise the functions won’t work correctly if you don’t use the pipeline.
Hi Allan ,
Firstly , much appriciate your hard work to made our life easy with this script.Also wondering we can add a little plugin that will also list the VM’s got network adapter disconnected. Something like the following I got from google search…
$ConnectedExp = @{ Name = “Connected”; Expr = { ($_ | Get-NetworkAdapter).ConnectionState.Connected } }
get-vm | select name, $ConnectedExp | where-object { !$_.Connected }
Ashraf
Is there a way of running the plugs w/o getting the “do not run/run/suspend” prompt?
Pingback: vCheck Exchange Updated | | Virtu-Al.NetVirtu-Al.Net
Hello, firstly great script – thank you for all the effort!
I am getting an oddity with the datastore overallocation script, it is reporting that several datastore are overallocated by varying percentages – however all the datastores in question only house “thick” disks and are not showing as overallocated in vCenter.
is anyone else seeing something similar?
ta
martin.
@alan, unsubscribe is still a pain in the ass… 🙂
This is the management page for following blogs. You will receive an email at xxxxx@gmail.com whenever a new post is made on these sites. Unfollow a blog to stop receiving emails from that blog.
You are not actively following any blogs. <—– uhm i'm not subsribed ???
If you are expecting to see blogs that you are following here please check that you used the same email address and that they are not still pending.
Was hoping, Alan, you or someone else could reply to my previous post.
If I run this tool on a VM, results on the Datacenter in which the VM resides
are returned. If I run the tool (same credentials, etc) from a physical device that is not managed by the vCenter, I see results of Datacenters.Is this standard behaviour? Do I need to configure or modify the script in any way to report on all (other) Datacenters when running from a VM managed by the vCenter that is being checked?
Thx
upgraded to PS 5.0.1 and still cannot get “Creator” field to populate for snapshot report.
can anyone share the fix? thanks
awesome script, al.
For anyone who wants to unsubscribe from the comments of this site, I think you can do it from this site here: https://subscribe.wordpress.com/ under the comments section.
Ignore the above one, after reading some of the replies I removed PowerCLI 5 and rebooted and reinstalled which sorted it out.
Hi, love the new version of the script, two issues with 52 and 71 which using the new PowerCLI you get the following errors:
Get-Datastore : Cannot validate argument on parameter ‘Datacenter’. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck\Plugins\52 Datastore Consistency.ps1:8 char:55
+ $Datastores = $VMHosts | Get-Datastore <<<<
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck\Plugins\52 Datastore Consistency.ps1:9 char:104
+ $problemDatastores = $VMHosts | ForEach {Compare-Object $Data
stores ($_ | Get-Datastore <<<< )} | ForEach {$_.InputObject} | Sort Name | Sel
ect @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it
is null.
At C:\vCheck\Plugins\52 Datastore Consistency.ps1:9 char:72
+ $problemDatastores = $VMHosts | ForEach {Compare-Object <<<<
$Datastores ($_ | Get-Datastore)} | ForEach {$_.InputObject} | Sort Name | Sel
ect @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Compare-Object], ParameterBind
ingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.PowerShell.Commands.CompareObjectCommand
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck\Plugins\52 Datastore Consistency.ps1:8 char:55
+ $Datastores = $VMHosts | Get-Datastore <<<<
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Get-Datastore : Cannot validate argument on parameter 'Datacenter'. The argumen
t is null or empty. Supply an argument that is not null or empty and then try t
he command again.
At C:\vCheck\Plugins\52 Datastore Consistency.ps1:9 char:104
+ $problemDatastores = $VMHosts | ForEach {Compare-Object $Data
stores ($_ | Get-Datastore <<<< )} | ForEach {$_.InputObject} | Sort Name | Sel
ect @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Get-Datastore], ParameterBindi
ngValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.GetDatastore
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it
is null.
At C:\vCheck\Plugins\52 Datastore Consistency.ps1:9 char:72
+ $problemDatastores = $VMHosts | ForEach {Compare-Object <<<<
$Datastores ($_ | Get-Datastore)} | ForEach {$_.InputObject} | Sort Name | Sel
ect @{N="Datastore";E={$_.Name}},@{N="Cluster";E={$Cluster.Name}} -Unique
+ CategoryInfo : InvalidData: (:) [Compare-Object], ParameterBind
ingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.PowerShell.Commands.CompareObjectCommand
10:53:34 ..finished calculating Datastore Consistency by Robert Sexstone v1.1
Attempted to divide by zero.
At C:\vCheck\Plugins\71 Capacity Planning.ps1:12 char:131
+ $DasRealCpuCapacity = $cluv.Summary.EffectiveCpu – (($cluv.Summar
y.EffectiveCpu * $cluv.Configuration.DasConfig.FailoverLevel)/ <<<< $cluv.Summa
ry.NumEffectiveHosts)
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
Attempted to divide by zero.
At C:\vCheck\Plugins\71 Capacity Planning.ps1:13 char:137
+ $DasRealMemCapacity = $cluv.Summary.EffectiveMemory – (($cluv.Sum
mary.EffectiveMemory * $cluv.Configuration.DasConfig.FailoverLevel)/ <<<< $cluv
.Summary.NumEffectiveHosts)
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
Attempted to divide by zero.
At C:\vCheck\Plugins\71 Capacity Planning.ps1:12 char:131
+ $DasRealCpuCapacity = $cluv.Summary.EffectiveCpu – (($cluv.Summar
y.EffectiveCpu * $cluv.Configuration.DasConfig.FailoverLevel)/ <<<< $cluv.Summa
ry.NumEffectiveHosts)
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
Attempted to divide by zero.
At C:\vCheck\Plugins\71 Capacity Planning.ps1:13 char:137
+ $DasRealMemCapacity = $cluv.Summary.EffectiveMemory – (($cluv.Sum
mary.EffectiveMemory * $cluv.Configuration.DasConfig.FailoverLevel)/ <<<< $cluv
.Summary.NumEffectiveHosts)
+ CategoryInfo : NotSpecified: (:) [], RuntimeException
+ FullyQualifiedErrorId : RuntimeException
10:34:52 ..finished calculating QuickStats Capacity Planning by Raphael Schitz,
Frederic Martin v1.3
Any Ideas?
Thanks M
Hi there,
I’ve made a little adjonction to the plugin 68 : Disk Max Total Latency.
As I’ve said earlier, when running this script some errors were displayed in the PowerCli shell. After searching, I’ve found that my vCenter isn’t collection data for some of my ESXi servers.
So I’ve upgraded this script to include such case. It’s just a little try / catch and the script will show in red the hosts with no stats.
# Start of Settings
# Disk Max Total Latency Settings in Milliseconds
$diskmaxtotallatency ="50"
# Disk Max Total Latency range to inspect (1-24)
$stattotallatency =" 24"
# End of Settings
$HostsDiskLatency = @()
foreach ($VMHost in $VMH | ?{$_.ConnectionState -eq "Connected"}) {
if ($VMHost.Version -lt 4){continue}# not an esx 4.x host
$HostDiskLatency = @()
$ErrorActionPreference = "stop"
try {
$VHHMaxLatency = $VMHost | get-stat -stat "disk.maxTotalLatency.latest" -start ($Date).addhours(-$stattotallatency) -finish ($Date)|?{$_.value -gt $diskmaxtotallatency}|sort Timestamp -Descending
if ($VHHMaxLatency.Count -gt 0) {
$Details = "" | Select-Object Host, Timestamp, milliseconds
$Details.host = $VMHost.name
$Details.Timestamp = $VHHMaxLatency[0].Timestamp
$Details.milliseconds = $VHHMaxLatency[0].Value
$HostDiskLatency += $Details
if ($VHHMaxLatency.Count -gt 2) {
$vmhlatid = [int]"1"
while ($vmhlatid -cle $VHHMaxLatency.Count-2) {
if (($VHHMaxLatency[$vmhlatid].timestamp).addminutes(5) -gt $Details.Timestamp -or ($VHHMaxLatency[$vmhlatid].timestamp).addminutes(-5) -gt $Details.Timestamp) { # keeps only high values strictly 5 min to avoid flood period
$Details = "" | Select-Object Host, Timestamp, milliseconds
$Details.host = $VMHost.name
$Details.Timestamp = $VHHMaxLatency[$vmhlatid].Timestamp
$Details.milliseconds = $VHHMaxLatency[$vmhlatid].Value
$HostDiskLatency += $Details
}
$vmhlatid++
}
}
}
} catch {
$Details = "" | Select-Object Host, Timestamp, milliseconds
$Details.host = "" + $VMHost.Name + ""
$Details.Timestamp = "Error Collecting Statistics"
$HostDiskLatency += $Details
}
$HostsDiskLatency += $HostDiskLatency
}
$HostsDiskLatency
$Title = "Disk Max Total Latency"
$Header = "Disk Max Total Latency over $diskmaxtotallatency"
$Comments = "Check vm per LUN dispatch and esxtop for very high values over $diskmaxtotallatency"
$Display = "Table"
$Author = "Raphael Schitz, Frederic Martin"
$PluginVersion = 1.1
$PluginCategory = "vSphere"
@Alan
Thanks for all the info and for pointing me in the right direction. I’ll submit the plugin if all goes well so that it can be included in future vChecks. 🙂
Kenny, unfortunately I dont have time to look into that plugin but if you ask on the PowerCLI community you will probably get an answer which you can copy and paste into a plugin, I would start with the Get-ViEvent cmdlet and LucD.info has some great posts on how to use that.
@Kenny and @Ben, the functions dont need to run in 1 script, just one session, I normally bring it up in PowerGUI Script Editor and run it there so the variables and functions are resident in my session, you can then run each check individually and edit as needed.
David, looks like i forgot to make use of the $TimeToRun disable.. Doh ! I will make sure this is updated in the next release.
Thank you Alan. I am sure you will get it resolved.. 🙂
p.s. I love this site btw. So it is no way a reflection on the work you provide to the community.
Keep up the great work.
Pete, im sorry but the unsubscribe button for the plugin in wordpress doesnt seam to work, im looking into this.
Ok – how do we unsubscribe?? No offense agaist quaality posts but i need to do some house keeping. Either I write a rule (which I dont want to ) or unsibscribe and check back regulary.
Also folks that post nothing or a simple period is a waste of time for me to read.
for this post i put in a ficticious email address so I can get my kind message across
.
@Alan
Any help or guidelines with setting up my suggested hardware change plugin earlier this week? I know all the data is available from vCenter, just need some assistance in bundling it all up in a plugin.
Would be greatly appreciated. 🙂
@David
I think the easiest way to achieve this is to # out the commands from within the vCheck.ps1 script. Edit the vCheck.ps1 script, then find the following text “This report took”. At the beginning of this line insert a #
The following three lines underneath should also have a # (4 in total)
Save and close the vCheck.ps1 script and then run it. If at any point you’d like this included in your report again, then edit and remove these these changes.
@Ben
From what I understand, PowerCLI scripts that contain variables and functions should always run in one script. ie If your variables and functions are defined in script1.ps1 and script1.sp1 is run from the cmdlet window and the same variables are called in script2.ps1, then when you try to run script2.ps1 from the cmdlet window, PowerCLI will not recall the variables defined originally from script1.ps1. vCheck.ps1 has reference to all the variables defined in all the scripts. Try the following to resolve your issue. Create a blank script, call it Snapshot.ps1. Edit Snapshot.ps1 and add the function “Write-CustomOut” from the vCheck.ps1 script. This will prevent a pile of errors that will display on your cmdlet window. Under this function, copy each script code in the order Alan mentioned above, first the global script code, then the 00 Connection code, followed by the 02 Snapshot code. Save and close the Snapshot.ps1 script you just created and run it from the cmdlet window. You should get an output, because the variables and functions are defined and referenced in the same script, just like the vCheck.ps1 script is.
How do I disable feature: timetorum “This report took ## minutes to run all checks”?
Thanks
Not sure if this is normal behaviour or not but I’m getting different results when I run this tool from a standalone, physical device as opposed to a VM within a vCenter.
To be precise, the standalone device reports on every Datacenter configured within the vCenter whereas the VM will only return results from the Datacenter in which it resides.
If this is indeed normal, can the script be particularized to report on all (other) Datacenters when running from a VM managed by vCenter?
Hum, no go still. If I ignore the customout bit it still says “unable to connect to vCenter, please ensure you have altered the vCenter server address correctly”
If I run the globalvariables then type $server it shows blank so I’d guess that its not retaining the variable and then of course the connection script won’t finish.
Ben, ah ok, yeah try the globalvariables then 00 plugin, dont worry about the custom out bit and then your plugin, i forgot i moved some stuff out to make it more generic for other reports.
Hey Alan!
Hum, I can definitely run it by copying just what I need however I can’t seem to run just 1 script if needed. I tried to run the 00 script first but it errors out with “write-customout” is not recognized as the name of a cmdlet, function, script file…. it then states it cannot connect to the server.
I did try connecting manually first without luck and also tried running to global variables script first. Sorry still new to these scripts so probably missing something simple.
Ben, Exactly, you can either run the 00 connection script and then the individual plugin in the same session, this will give you an output in your Powershell session for that particular plugin or you can copy the folder and delete the other plugins you dont want, either way will work.
Thanks for all of this, great stuff in here and very useful !!
Quick question that I couldn’t find and answer for, apologize if its here somewhere. Is there a way to run just 1 plugin “one off” so say I would like to run mid day today and find out the snapshot info. Can I run the main vcheck.ps1 with variables to only run the 1 check or would I need to just copy it to a new folder and have just the 1 plugin? I tried some of the scripts but they couldn’t run on their own likely missing the global variables. I could modify but wondered if this already exists.
thanks again!
Thanks Alan, it works as expected in PowerCLI 5.0.1 … I’ve had 5.0.0 installed before …
Pingback: vCDAudit for vCloud Director | | Virtu-Al.NetVirtu-Al.Net
MS, please can you check your using the latest version of PowerCLI, this was an issue with Version 5.0 of PowerCLI. Thanks
I am using vCheck 6.15 and I am a bit confused by Datastores (Less than x% free) plugin result. It says that my datastore has CapacityGB of 110,08 and FreeSpaceGB od 799,75. Shouldn’t that be reversed?
Hi, how do I disable “This report took ## minutes to run all checks.
If I set to false or False it still reports time.
Thanks
$TimeToRun = $False
Kenny: agree with you completely.. i have had trouble in the past with this.. few dumb guys would add HDDs to VMs and never use it to its max too… this would really be a good add 🙂
Just switched over from vCheck v5 to v6. The plugins feature is very handy and customising the script is now effortless. Thanks Alan, and everyone else who has contributed to making this the best admin utility ever! Now, may I pick your brains for a second… Would it be possible to create a plugin that can display any hardware changes made to a VM between vChecks? (I run mine weekly, so the result should only show the last 7 days.) Especially CPU, MEM, adding of Hard Drives or disk space changes. This would really help admins monitor resource usage and allocation, along with troubleshooting VM performance issue when checking the report history on hardware changed.
@Alan, no way it is just that i check the site every week for news, so i don’t need a notification email send everytime..
So keep up the good work Alan !
c0de1, sorry about that, I will take a look and see why it isnt working… Was it something we said 😉
unsubscribe is not an option here i think ??
Can’t unsubscribe here ?
I can press “manage your subscripton” but i can’t unsubscribe there, can someone help me with this ?
Pingback: vCheck for Exchange 2010 - Virtu-Al.NetVirtu-Al.Net
Thats not a bad idea, the 00 plugin could actually be written to present a nice GUI, i have also thought about a dynamic GUI for the configuration with an export and import feature but that may take a little time to develop 😉
I guess what will really be a cool feature to add (after all the testing and finalization is done 🙂 ) is a neat yet simple GUI to run all this.. i guess that will really make this a proper solution rather than just a tool/ utility…
something similar to http://www.virtu-al.net/featured-scripts/ha-drs-audit/
Thanks alot Phill and Alan..
This makes work more simplier and yet fun to work with.. this is exactly what i wanted.. !! Awesome work !!
Alan: Yes, i will mention the original work and credits in the new script.. will share it once its completed..
Thanks alot 🙂
Awesome work 🙂
All going well, Alan will release the Exchange Plugins on Monday.
Meanwhile, Alan’s left a teaser on the vCheck Facebook page:
http://www.facebook.com/photo.php?fbid=365684133452172&set=a.365684130118839.83559.365674406786478&type=1
And don’t forget to follow @vCheckUpdates on Twitter
And here we go,
One vCheck Plugin to Rule Them All
I’d recommend running it standalone, and not as a plugin, but it does have its potential uses as a plugin.
@kenny
The initial Exchange 2010 plugins are about to be released. Watch this space
@Alan
Fantastic release and updates man! Works beautiful.
@Phil and Alan,
Did you guys stop work on the exchange plug-in? I was stoked for that one..
Thanks a ton both of you for all of the hard work!
@Yohan
Your prayers have been answered.
I’ve just written the ultimate plugin (yes, plugin!) which configures plugins as active or disabled via a simple Windows GUI.
It will be winging its way to Alan very shortly
How do you unsubscribe from this thread? I click on Manage your subscriptions at the bottom of this thread but it just takes me to another site on your webpage with no way to unsubscribe. Alan can you take a look into this and see what’s wrong with the link? Thanks
Plugin : 68 Disk Max Total Latency.
I’ve find with the help of the script that 3 of my esx server wasn’t sending stat to vCenter. After googling a little, it seems that it’s a problem which is not so isolated. I’ve been able to correct this by remove the host and adding it again in the vCenter.
As the problem is occuring time to times, and as I’m not as good as Powershell as I would like, I’m asking for help here. One thing which should be nice is that the script send alert when no stat is collected. Problem the command : $VMHost | get-stat return an error if stat are “broken”, and I don’t know if it’s possible to catch the error in PowerShell.
I hope I was clear enought to describe the problem !
@Phil : thx for the tips, but I’ve done it as soon as I’ve point the error 🙂
Sybux,
Renaming datastores is even easier than I thought!
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006279
Sybux,
You’d save yourself a bit of grief if you renamed the datastore – I suspect that means moving everything off it, renaming, and moving back.
At some point a human’s likely to get confused as to which datastore’s where 🙂
Yohan,
It should be possible to write a PS script which (for example) reads all plugins in Plugins directory with .ps1 and .ps1.disabled extensions and fill up a menu with a checkbox against each one. And then script the renaming of extensions according to the checkmarks.
is it possible to allow the user to select the plugins he wants to run using some menu-driven approach??
if yes.. then any ideas on how to go about it??
@alan : i thought also, but as soon as I’ve change the variables, the error disapeared. Perhaps it’s something in my configuration of PS ?
Plugin 64 Snapshots Oversize .
I’m getting a little issue. In my vCenter, I got 2 Datacenters, and in those datacenter, there is datastore with the same name. Problem, when the scripts run in line : $dsb = Get-View (($ds | Get-View).Browser) it fails as there is more than 1 line.
So question : is it possible to limit the search on the datacenter hosting the VM or stop and Warn user if there is more than one occurence of a datastore name ?
Sybux, are you kidding ? You do know that PowerShell doesn’t care about the case of a variable name ? or am i missing something here ?
Release 6.15 :
there is a little error in plugin 00 Connection Plugin for vCenter
at line 92, it should be :
$alarmMgr = get-view $ServiceInstance.Content.alarmManager
with a capital S at ServiceInstance.
—- vCheck 6.15 released —-
# v 6.15 – Added Category to all plugins and features to vCheckUtils script for Categorys.
# v 6.14 – Fixed a bug where a plugin was resetting the $VM variable so later plugins were not working 🙁
# v 6.13 – Fixed issue with plugins 63 and 65 not using the days
# v 6.12 – Changed Version to PluginVersion in each Plugin as the word Version is very hard to isolate!
# v 6.11 – Fixed a copy and paste mistake and plugin issues.
Thanks Robert, updated for next release.
In the plugins “63 Snapshots removed.ps1” and “65 Snapshots removed.ps1” the selection for the number of days on which to report was not implemented. I modified the Get-VIEvent command in both scripts into:
Get-VIEvent -maxsamples $MaxSampleVIEvent -Start (Get-Date).AddDays(-$VMsNewRemovedAge)
Oh I had another question, anyway to exclude specific DiskPaths aka say /boot from VMs with less than X MB ?
Think its :
19 Guests with less than X MB free.ps1
I think it only prompted me once for my username and password. Whats odd though is my vcenter is using the same local windows userid\password even if it prompted me once it should be the same? my user is in the admin group as well as currently we don’t have AD.
With vCheck 6.10, you can rename a plugin to something like “60 Powered Off VMs.ps1.disabled” and it will be ignored. Sometimes renaming is more convenient than deleting.
Cheers,
Phil
Pingback: Mise à jour vCheck 6.10 | vmdude
Shane, Ahh yeah, I see. So if its an issue and you are not really interested in when VMs were Powered Off then I would remove that file from the plugins folder, thats the great thing about this script !
That particular script does take a while gathering the events and sorting them out to find out when it was powered off.
HELP!
I want to unsubscribe from the comments for this post.
The “To manage your subscriptions or to block all notifications from this site, click the link below” does not take me anywhere I can see how to do so.
Great script, but 500+ comments are filling my mailbox 😉
thanks
That is what I said, the Powered off VM’s took 21 minutes
This report took 39.48 minutes to run all checks.
The following plugins took longer than 30 seconds to run, there may be a way to optimize these or remove them if not needed
01 General Information.ps1 51.77
02 Snapshot Information.ps1 37.51
27 VM Tools Issues.ps1 73.51
32 VM CPU Percent RDY.ps1 134.83
33 VM CPU Usage.ps1 299.53
48 FindVmDiskFormat.ps1 74.28
60 Powered Off VMs.ps1 1275.58
63 Snapshot removed.ps1 59.26
65 Snapshot created.ps1 51.27
71 Capacity Planning.ps1 80.08
There should be the plugin details at the bottom which tells you how long it takes, post them here and we can see which ones potentially need tuning.
@Phil. You are right. I didn’t think of anything else than vSphere to use this script for. You can remove the
if (-not $VIServer) { throw “VIServer parameter must be specified.”}
line from my change. This will make the -VIserver parameter not mandatory.
The script runs great for me – except the length of time. On one cluster, I only have 14 Datastores and 86 VM’s and it takes 21 minutes to query plugin 60, for powered off VM’s. The overall script taking 39 minutes, with the one step, 21 of those.
James, did you run through the setup video ? It tells you that these scripts require access to the vCenter Windows machine and therefore you will be prompted for access the first time if your credentials which are passed through do not work. If they dont work it prompts you and saves these in the vCheck folder with a filename of Windowscreds.xml, if the credentials you entered the first time are wrong for your windows vCenter box then delete this file and try again.
One thing I do see now is this though:
10:19:42 AM ..finished calculating VCB/Veeam/NetBackup Garbage by Alan Renouf v1.1
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\scripts\vCheck\Plugins\41 vCenter Services.ps1:7 char:27
+ $Services = get-wmiobject <<<< -Credential $creds win32_service -ComputerName $VIServer | Where {$_.DisplayName -like "VMware*" }
+ CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
10:19:42 AM ..finished calculating VC Services by Alan Renouf v1.1
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\scripts\vCheck\Plugins\42 Windows vCenter Error Event Logs.ps1:12 char:24
+ $WMI = @(Get-WmiObject <<<='” + $ConvDate + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”TimeGenerated”;E={$_.ConvertToDateTime($_.TimeGenerated)}},
Message)
+ CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
10:19:42 AM ..finished calculating Windows vCenter Error Event Logs by Alan Renouf v1.1
Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
At C:\scripts\vCheck\Plugins\43 Windows vCenter Warning Event Logs.ps1:8 char:24
+ $WMI = @(Get-WmiObject <<<='” + $ConvDate + “‘”) | Where {$_.Message -like “*VMware*”} | Select @{N=”TimeGenerated”;E={$_.ConvertToDateTime($_.TimeGener
ated)}}, Message)
+ CategoryInfo : NotSpecified: (:) [Get-WmiObject], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
Robert,
Nice, but it ignores the fact that the framework might be used in a non-vmware environment where the scripts aren’t checking a specific server by name.
Alan’s got my Exchange 2010 examples which demonstrate this
The Server parameter should be optional, not mandatory.
I’ve just upgraded to release 6.10 but I get many errors :
Get-View : Cannot validate argument on parameter ‘VIObject’. The argument is nu
ll or empty. Supply an argument that is not null or empty and then try the comm
and again.
At C:\vCheck6\Plugins\64 Snapshots Oversize.ps1:33 char:28
+ $dsb = Get-View <<<< (($ds | Get-View).Browser)
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
You cannot call a method on a null-valued expression.
At C:\vCheck6\Plugins\64 Snapshots Oversize.ps1:44 char:71
+ $taskMoRef = $dsb.Client.VimService.SearchDatastoreSubFolders_Ta
sk <<<< ($dsBrowserMoRef, $dir, $searchSpec)
+ CategoryInfo : InvalidOperation: (SearchDatastoreSubFolders_Tas
k:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\vCheck6\Plugins\64 Snapshots Oversize.ps1:45 char:67
+ $task = [VMware.Vim.VIConvert]::ToVim($dsb.WaitForTask <<<< ([VMw
are.Vim.VIConvert]::ToVim($taskMoRef)))
+ CategoryInfo : InvalidOperation: (WaitForTask:String) [], Runti
meException
+ FullyQualifiedErrorId : InvokeMethodOnNull
One other thing is that every is at twice ??
I added the possibility to specify a vCenter server as a parameter to the vCheck script. To do this I modified vCheck.ps1 in the following way:
I changed the first line of the script into:
param ($VIServer, [Switch]$config, $Outputpath)
if (-not $VIServer) { throw “VIServer parameter must be specified.”}
$VISRV = $VIServer
And I modified the line:
. $GlobalVariables
into:
. $GlobalVariables -VIserver $VIServer
I modified GlobalVariables.ps1 and inserted the following line at the beginning of the script:
param($VIServer)
And modified the line that starts with $Server into:
$Server =$VIServer
No probs James, that will teach you to use an existing name 😉
Brian, is there an unsubscribe link at the bottom of this page ?
Found the issue. Seemed to be a split-path custom function I put in the profile at some point. I removed that and now its working normally. Sorry about that.
Thanks
James,
Try upgrading to PowerCLI 5.0.1
Alan,
PS C:\scripts> $Host.Version
Major Minor Build Revision
—– —– —– ——–
2 0 -1 -1
Running on Win7 x64
PowerCLI C:\scripts> Get-PowerCLIVersion
PowerCLI Version
—————-
VMware vSphere PowerCLI 5.0 build 435427
—————
Snapin Versions
—————
VMWare AutoDeploy PowerCLI 5.0 build 575
VMWare ImageBuilder PowerCLI 5.0 build 575
VMware License PowerCLI 5.0 build 395016
VMWare vSphere PowerCLI 5.0 build 435427
how can i unsubscribe here ?
Sorry Yohan, yes please do use my script, I am pleased for anyone to re-use this structure so long as they keep a link to the original somewhere !
Don’t forget to share your work with me if it can be shared and would be useful to others.
Hi Alan,
Any word on this front..
I need to get started ASAP..
http://www.virtu-al.net/featured-scripts/vcheck/#comment-14561
Thanks..
James, what version of PowerShell are you using ? I haven’t seen this anywhere else ?
Hi Alan, it’s now possible to specified a cluster?
Regards
Sven
Pingback: vCheck 6.10 update
Pingback: Mise à jour vCheck 6.10
Still seeing something weird with the Path ??
———————————-
PS C:\scripts\vCheck> ./vCheck.ps1
Get-ChildItem : Cannot find path ‘C:\scripts\vCheck\Path’ because it does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (C:\scripts\vCheck\Path:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find path 'C:\scripts\vCheck\====' because it does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (C:\scripts\vCheck\====:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '1 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (1 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '2 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (2 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '3 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (3 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '4 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (4 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '5 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (5 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '6 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (6 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '7 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (7 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '8 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (8 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '9 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (9 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '10 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (10 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '11 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (11 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find drive. A drive with the name '12 ' does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (12 :String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Cannot find path 'C:\Plugins\' because it does not exist.
At C:\scripts\vCheck\vCheck.ps1:64 char:25
+ $Plugins = Get-ChildItem <<<< -Path $PluginsFolder -filter "*.ps1" | Sort Name
+ CategoryInfo : ObjectNotFound: (C:\Plugins\:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-Content : Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\scripts\vCheck\vCheck.ps1:67 char:20
+ $file = Get-Content <<<< $GlobalVariables
+ CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Get
ontentCommand
Alan and all the plugin authors, thanks for the update!
Really glad the VMKernel warnings are back in 6.1.
I have a few issues with the new version, running it in vSphere 4.1:
The Missing ESX Patches.ps1 script runs 240 seconds and doesn’t produce output in the report.
Storage IO Enabled script not reporting correctly, it shows all my datastores as not having it enabled and it is enabled.
Snaps created and snapshots removed scripts report every single snapshot in the logs, not just 5 days worth….changing to 1 day didn’t help.
Owen, as far as the e-mail to multiple people issue, I do go back and edit the setting to include parens around each recipient. The script initially includes parens around the group of addresses and not each address, and that doesn’t seem to work.
Pingback: vCheck updated to 6.10 | | Virtu-Al.NetVirtu-Al.Net
———– vCheck 6.10 Released ———–
The new version doesn’t appear to allow multiple email addresses to be listed in the $EmailTo parameter. In v5 we could have multiple addresses seperated by a single comma which doesn’t work in this new version. Is there a way to get this functionality back? Love the script by the way!
Thanks for vCheck 6!!! I like the modular approach. I’ve been deep diving into PowerCLI for the past 3 months and your site along with the PowerCLI reference book have been a great learning source. I was able to update the snapshot report to get creator name successfully. Thanks for your hard work!!
Hi Alan,
I have been testing your script out for sometime now on my Test Lab…
I wish to make few design changes in it and then possibly demo it to our organization’s internal Infrastructure Management Team..
So i need your permision to use this script of yours as a template and possibly design something around it for our own internal use..
Do note that this will, in no way be used for any monetory-like purposses…
This will solely be used by our internal teams..
Do let me know your thoughs on this..
Thanks alot..
Awesome work… 🙂
JT, I am sorry, please do get in contact and I will give you a full refund on this script.
I just ran the report an everything looks great except I don’t get results for vm’s created and the results for vm’s removed seems to be off. Any idea’s?
I want to run this multiple times a day (management requesting it) – is there a way to add the time to the end of the HTML file so it keeps multiple files in the same directory, as I run it?
Great script by the way I use it all of the time. I have a question about the VM(s) CPU above 90. Would it be possible to display the process on that machine that is above 90%? Here is the code that you can use to return the top process on the remote machine I just don’t know how to incorporate it into your vCheck script? Thanks
$sample_interval_seconds = 1
$num_procs = @(gwmi -co $compname -cl win32_processor).count
$ctrs = (Get-Counter -computername $compname “\Process(*)\% Processor Time” -sampleinterval $sample_interval_seconds).CounterSamples | `
where { $_.InstanceName -ne “_total” -and $_.InstanceName -ne “idle” } | sort-object CookedValue -desc
$ctrs[0..0] | %{“$compname” + ” ” + $_.InstanceName + ” ” + [int]($_.CookedValue / $num_procs) + “%”}
}
Thank you Alan firstly for providing this script. While running it, I got a Warning: There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated in a root certification which isn’t trusted by the trust provider.
* The X509 chain is not valid due to an invalid time value, shuch as a value that indicates an expired certificate.
* The certificate’s CN name does not match the passed value.
The scripts continue with the Collecting part of things but doesn’t seem to go on with the plug-in. Would the certificate issue be the cause of it?
In v6, I’ve noticed some weirdness with the snapshot size calculation. When I execute the code from the “02 Snapshot Information.ps1” file, I get the correct snapshot sizes, but the HTML file contains different (wrong) information. Everything else about the snapshot is correct, just the SizeMB is incorrect. It looks like you’re just taking that data and pushing it into the HTML file, so I don’t know where it might be breaking.
Is there a way, to add to this script, to give you an inventory of the data stores? Basically, I want to know what VM’s, by name, live on each Data store in the infrastructure.
Is it possible to add in the “Capacity Planner Info” section to also add in DataCenter Name to? with the cluster name .?
Pingback: Enable the VMware balloon driver vmmemctl to prevent swapping in an imported Linux VM « Yuri's Technology Blog
I am disappointed in this script!!!!! Can’t get VMkernel errors to report! Previous one was much beter!
Is there any plugin to let us know how long the VM has been running without someone logging onto it locally or by RDP?
Alan, thank you for all your great work on providing this script.
Thanks for all the comments I have fixed most of these issues in the next version which I will upload soon.
There also seems to be an issue with the HWversion plugin: $_.hwversion doesn’t seem to be a valid use of the property.
I noticed that most of the headers in the report omit the actual value that they’re configured to report on. For instance: “Datastores (Less than % Free):” rather than “Datastores (Less than 20% Free):”.
It seems that this is happening because the variable is defined after the header output. The simplest way I found to fix this is to move the “settings” section to the top of the plugin script.
Hope that helps.
-Jon
I’im using vCheck V6
Great scrit but i have a little problème.
The first time i receveid the mail with .htm file.
Then if i execute again i had an error:
17:32:13 ..Sending Email
Send-MailMessage : Impossible de valider l’argument sur le paramètre « Attachme
nts ». L’argument est null ou vide. Indiquez un argument qui n’est pas null ou
vide et réessayez.
Au niveau de C:\Scripts\vCheck\vCheck.ps1 : 385 Caractère : 154
+ send-Mailmessage -To $EmailTo -From $EmailFrom -Subject “$VISRV vChec
k Report” -SmtpServer $SMTPSRV -Body “vCheck attached to this email” -Attachme
nts <<<
******************************************************
Vcenter 2.5
power shell v2
power CLI 5.0.1
Great script, however I am having one problem. To stop me from running the script against all the datastores on the network i have locked it down. By locking it down I mean that I have created a new user in Active Directory and have added this users as an administrator to the ESX hosts, folders, datastores and networks i want to pool. Everything is fine but for the datastores. I just will not gather data for me. I get this error when I run the script.
Get-Datastore : 23/02/2012 5:19:41 PM Get-Datastore Object reference
not set to an instance of an object.
At C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vCheck5\Global
Variables.ps1:77 char:28
+ $Datastores = Get-Datastore <<<< | Sort Name
+ CategoryInfo : NotSpecified: (:) [Get-Datastore], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio
n.ViCore.Cmdlets.Commands.GetDatastore
Now if I run the same script against one esx server with root authentication its fine. So I figure it must be something to do with permissions. Any ideas. I get this part right, im sorted!! its only the datastore that is giving me issues. Do I need to hardcode something?
Great Report but it doesn’t display all the results, like VMkernel errors???? PLEASE HELP!
@John
Should be fairly simple – see here for the gory details:
http://blogs.technet.com/b/heyscriptingguy/archive/2010/09/23/use-powershell-cmdlets-to-manage-sharepoint-document-libraries.aspx
http://poshcode.org/2122
Awesome! great work, Alan! you make VI admins life easier.
Is there a way to publish this report directly to a SharePoint site?
never mind the last comment after upgrading from PowerCLI 5.0 to 5.1 the scripts completed without error.
I am getting a StackOverflowException right after VM needing snapshot consolidation by Luc Dekens v1.0
Any thought?
Alan,
how can i unsubscribe here ?
@alan – thanks for this new version of vCheck, it’s awesome!
@billywestbury
I had the same problem, PowerCLI 4.1 reports in MB not in GB. So you need to change CapacityGB to CapacityMB and FreeSpaceGB to FreeSpaceMB in Datastore Information.ps1.
Like this:
$OutputDatastores = @($Datastores | Select Name, Type, CapacityMB, FreeSpaceMB, PercentFree| Sort PercentFree)| Where { $_.PercentFree -lt $DatastoreSpace }
Love the script, we use it to report on multiple client vm environments.
We have modded this into a daily, weekly, monthly report so we get only the information we want on a particular day.
replace the first (param) line with
param(
[Switch]$config,
$Outputpath,
[parameter(Mandatory=$true)]
[ValidateSet(‘Daily’,’Weekly’,’Monthly’)]
$ReportType
)
then change this line:
$PluginsFolder = $ScriptPath + “\Plugins\”
to:
$PluginsFolder = $ScriptPath + “\$ReportType\”
(plus a few other tweaks to get the email subline line changed etc..)
then make a Daily, Weekly, Monthly subfolder, and move the appropriate checks into each folder
Thanks for the great script. Is there any plug in to have the output published on a Sharepoint site (SP 2010) instead of emailig it.
Re Exchange checking, it’s worth taking a look at Steve Goodman’s Powershell script:
http://www.stevieg.org/2011/06/exchange-environment-report/
@SomeITGuy
The SMTP server you’ve specified isn’t letting the box you’re running the script on talk to it. Telnetting to port 25 on $SMTPSRV might give you a clue as to what’s going on.
Seems like the free space check columns is backwards in the email report?
Name Type CapacityGB FreeSpaceGB PercentFree
esx02:internal VMFS 47.4833984375 69.5 68
Alan,
That was the problem, i still had CLI 4.0 installed along with 5.x. Removed both, rebooted reinstalled 5.x & it works now with the exception of this:
4:56:55 PM ..Sending Email
Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.3
.2 Service not available
At C:\Users\myname\my documents\scripts\vmware\vCheck.ps1:385 char:19
+ send-Mailmessage <<<< -To $EmailTo -From $EmailFrom -Subject "$VISRV vCheck Report" -Smt
pServer $SMTPSRV -Body "vCheck attached to this email" -Attachments $Filename
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailM
essage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
Love the new update, but I am still having an issue where the output doubles everything. example: I have 50 VMs in the Production environment and the output shows 100. Anyone else have this issue?
I want to add the ability to specify which data centers the script will check. Any suggestions would be great…
Hi Steve,
Alan’s working on it, and you’ll see what I meant soon when vCheck is updated. I keep sending Alan good/bad ideas, which might be delaying the release a little 🙂
Basically, with the next release, the vSphere checks can be completely disabled (because the vSphere initialisation part is now in a plugin), allowing you to use the vCheck framework to check whatever you want, even in a non-VMware environment.
I’ve had no problems with the email being sent here. It’s possible that your SMTP relay isn’t allowing connections from the box you’re running the script on.
Does anyone know why none of the counts and only some of the variables display in the HTML report?
Hi Phil,
excuse me if i sound totally green, but what do you mean in your comment about vSphere dependencies as follows:
To remove vSphere dependencies from the core, EndScript.ps1 should not be part of the core, but the last-called plugin (e.g. “99 vSphere Cleanup.ps1″)
Then the framework can be used for non-vSphere plugins in other, vSphere-free) environments.
Three-digit plugin numbers numbered in increments of 10 might be a good idea too.
Hi Al,
Amazing script that even a newby to powercli like me can get his head around, is there an eta on the changes that Phil has submited. also having problems getting the email to send.
SomeITGUy, Can you do a Get-PowerCLiVersion from PowerCLI, its strange that it isnt picking up the New-VIProperty command in your session.
Phil,
Making the changes right now, thanks. Also some of the ones you and others have emailed me. The Exchange one is Awesome, exactly what I wanted people to do. Soon we will have an army of vChecks !
@phil,
All of that information you mention is awesome! That would be great phil. I would love to see all of that on top of the vcheck! I anxiousley await for it…
🙂
@kenny, I’d be interested to know what info people would want to get out of Exchange 2010. So far, I’ve just hacked a couple of scripts I already had because I could 🙂
My proof-of-concept script listed Exchange 2010 databases, their sizes, amount of whitespace, number of mailboxes, average mailbox size, etc
I’ve also got one showing replication statuses of DBs.
@phil, @alan,
How is the vcheck + the exchange 2010 sample plugin coming along? I definitely want that!
@Alan:
I downloaded the latest version of PowerCLI & installed, now getting even more errors:
11:58:39 AM Adding Custom properties
The term ‘New-VIProperty’ is not recognized as the name of a cmdlet, function, s
cript file, or operable program. Check the spelling of the name, or if a path wa
s included, verify that the path is correct and try again.
At C:\users\myname\my documents\scripts\vmware\GlobalVariables.ps1:59 char
:15
+ New-VIProperty <<<< -Name PercentFree -ObjectType Datastore -Value {
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The term 'New-VIProperty' is not recognized as the name of a cmdlet, function, s
cript file, or operable program. Check the spelling of the name, or if a path wa
s included, verify that the path is correct and try again.
At C:\users\myname\my documents\scripts\vmware\GlobalVariables.ps1:64 char
:15
+ New-VIProperty <<<< -Name "HWVersion" -ObjectType VirtualMachine -Value {
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
11:58:39 AM Collecting VM Objects
11:58:40 AM Collecting VM Host Objects
11:58:40 AM Collecting Cluster Objects
11:58:40 AM Collecting Datastore Objects
11:58:41 AM Collecting Detailed VM Objects
11:58:43 AM Collecting Template Objects
11:58:43 AM Collecting Detailed VI Objects
11:58:43 AM Collecting Detailed Alarm Objects
11:58:44 AM Collecting Detailed VMHost Objects
11:58:46 AM Collecting Detailed Cluster Objects
11:58:46 AM Collecting Detailed Datastore Objects
11:58:48 AM ..finished calculating General Information by Alan Renouf v1.0
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
12:00:39 PM ..finished calculating Snapshot Information by Alan Renouf v1.0
12:00:39 PM ..finished calculating Datastore Information by Alan Renouf v1.0
12:00:39 PM ..finished calculating Map disk region event by Alan Renouf v1.0
12:00:39 PM ..finished calculating Hosts in Maintenance Mode by Alan Renouf v1.0
12:00:39 PM ..finished calculating Hosts Not responding or Disconnected by Alan
enouf v1.0
12:00:40 PM ..finished calculating Hosts Overcommit state by Alan Renouf v1.0
Get-View : 2/10/2012 12:00:40 PM Get-View Invalid object specified for
parameter Id – 'VMHostImpl'. Valid types are ManagedObjectReference and string.
At C:\users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun P
ath.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDevice
Info.ScsiLun |Measure-Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx1.myco.com:VMHostImpl)
[Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.
VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/10/2012 12:00:40 PM Get-View Invalid object specified for
parameter Id – 'VMHostImpl'. Valid types are ManagedObjectReference and string.
At C:\users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun P
ath.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDevice
Info.ScsiLun |Measure-Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx2.myco.com:VMHostImpl)
[Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.
VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/10/2012 12:00:40 PM Get-View Invalid object specified for
parameter Id – 'VMHostImpl'. Valid types are ManagedObjectReference and string.
At C:\users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun P
ath.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDevice
Info.ScsiLun |Measure-Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx3.myco.com:VMHostImpl)
[Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.
VimAutomation.Commands.DotNetInterop.GetVIView
Get-View : 2/10/2012 12:00:40 PM Get-View Invalid object specified for
parameter Id – 'VMHostImpl'. Valid types are ManagedObjectReference and string.
At C:\users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun P
ath.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDevice
Info.ScsiLun |Measure-Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx4.myco.com:VMHostImpl)
[Get-View], VimException
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.
VimAutomation.Commands.DotNetInterop.GetVIView
12:00:40 PM ..finished calculating Hosts Dead Lun Path by Alan Renouf v1.0
12:00:43 PM ..finished calculating Created or cloned VMs by Alan Renouf v1.0
12:00:43 PM ..finished calculating Removed VMs by Alan Renouf v1.0
12:00:43 PM ..finished calculating VMs with over x vCPUs by Alan Renouf v1.0
12:01:59 PM ..finished calculating VMs Ballooning or Swapping by Alan Renouf v1.
12:01:59 PM ..finished calculating Invalid or inaccessible VM by Alan Renouf v1.
12:02:01 PM ..finished calculating VMs restarted due to Guest OS Error by Alan R
nouf v1.0
12:02:02 PM ..finished calculating HA VMs restarted by Alan Renouf v1.0
12:02:02 PM ..finished calculating Host Swapfile datastores by Alan Renouf v1.0
12:02:03 PM ..finished calculating DRS Migrations by Alan Renouf v1.0
12:02:03 PM ..finished calculating Cluster Slot Sizes by Alan Renouf v1.0
12:02:04 PM ..finished calculating Guests with less than x MB by Alan Renouf v1.
12:02:04 PM ..finished calculating ESXi with Technical Support mode or ESXi Shel
enabled by Alan Renouf v1.0
12:02:04 PM ..finished calculating ESXi hosts which do not have Lockdown mode en
bled by Alan Renouf v1.0
12:02:04 PM ..finished calculating Checking VM Hardware Version by Alan Renouf v
.0
12:02:05 PM ..finished calculating Checking VI Events by Alan Renouf v1.0
Get-VirtualSwitch : A parameter cannot be found that matches parameter name 'Sta
ndard'.
At C:\users\myname\my documents\scripts\vmware\Plugins\24 vSwitch with les
s than x Ports Free.ps1:13 char:35
+ $VMH | Get-VirtualSwitch -Standard <<<< | Sort NumPortsAvailable | Where {$_.
NumPortsAvailable -lt $($vSwitchLeft)} | Select VMHost, Name, NumPortsAvailable
+ CategoryInfo : InvalidArgument: (:) [Get-VirtualSwitch], Paramet
erBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.Comma
nds.GetVirtualSwitch
12:02:05 PM ..finished calculating Checking Standard vSwitch Ports Free by Alan
enouf v1.0
12:02:05 PM ..finished calculating VMs in inconsistent folders by Alan Renouf v1
0
12:02:05 PM ..finished calculating No VM Tools by Alan Renouf v1.0
12:02:47 PM ..finished calculating VM Tools Issues by Alan Renouf v1.0
12:02:48 PM ..finished calculating CD-Roms Connected by Alan Renouf v1.0
12:02:49 PM ..finished calculating Floppys Connected by Alan Renouf v1.0
12:02:49 PM ..finished calculating Single Storage VMs by Alan Renouf v1.0
12:02:50 PM ..finished calculating NTP Name and Service by Alan Renouf v1.0
12:04:03 PM ..finished calculating VM CPU %RDY by Alan Renouf v1.0
12:07:14 PM ..finished calculating VM CPU Usage by Alan Renouf v1.0
12:07:19 PM ..finished calculating Number of VMs per Datastore by Alan Renouf v1
0
12:07:19 PM ..finished calculating Host Configuration Issues by Alan Renouf v1.0
12:07:28 PM ..finished calculating Host Alarms by Alan Renouf v1.0
12:07:28 PM ..finished calculating VM Alarms by Alan Renouf v1.0
12:07:28 PM ..finished calculating Cluster Configuration Issues by Alan Renouf v
.0
12:07:28 PM ..finished calculating Datastore OverAllocation by Alan Renouf v1.0
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
12:09:17 PM ..finished calculating VCB/Veeam Garbage by Alan Renouf v1.0
12:09:17 PM ..finished calculating VC Services by Alan Renouf v1.0
12:17:01 PM ..finished calculating Windows vCenter Error Event Logs by Alan Reno
f v1.0
12:24:50 PM ..finished calculating Windows vCenter Warning Event Logs by Alan Re
ouf v1.0
12:25:00 PM ..finished calculating VMKernel Warnings by Alan Renouf v1.0
You cannot call a method on a null-valued expression.
At C:\users\myname\my documents\scripts\vmware\Plugins\45 VMs needing snap
shot consolidation.ps1:11 char:40
+ $VM | where {$_.VMHost.ApiVersion.Split <<<< ('.')[0] -ge 5 -and $_.ExtensionD
ata.Runtime.consolidationNeeded} |
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExcep
tion
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\users\myname\my documents\scripts\vmware\Plugins\45 VMs needing snap
shot consolidation.ps1:11 char:40
+ $VM | where {$_.VMHost.ApiVersion.Split <<<< ('.')[0] -ge 5 -and $_.ExtensionD
ata.Runtime.consolidationNeeded} |
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExcep
tion
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\users\myname\my documents\scripts\vmware\Plugins\45 VMs needing snap
shot consolidation.ps1:11 char:40
+ $VM | where {$_.VMHost.ApiVersion.Split <<<< ('.')[0] -ge 5 -and $_.ExtensionD
ata.Runtime.consolidationNeeded} |
+ CategoryInfo : InvalidOperation: (Split:String) [], RuntimeExcep
tion
+ FullyQualifiedErrorId : InvokeMethodOnNull
Hey Al
Nice script, works great one question on the datastore usage should the capacity and free space columns have values in them? I just see the percent free column from my input value.
Thanks
Another change which would be very useful is to change the hardcoded email report
-Subject “$VISRV vCheck Report”
to use a variable which can be set in GlobalVariables.ps1 (or overridden in a plugin)
I’ve emailed Alan my changes, complete with a sample plugin which reports on Exchange 2010 Database statistics (requires Exchange Management Shell for the Exchange 2010 snapin).
My master plan revealed, to turn vCheck into an Exchange 2010 reporting tool :-p
Phil, Awesome stuff – keep it coming !
Francois, Thanks, I will loog at this.
I’m on a roll here:
Change line 64 to:
$Plugins = Get-ChildItem -Path $PluginsFolder -filter “*.ps1” | Sort Name
To make sure plugin loading is in a deterministic order.
Another suggestion is to take everything out of GlobalVariables.ps1 after “# End of Settings” and put into a plugin named “00 vSphere.ps1”
To remove vSphere dependencies from the core, EndScript.ps1 should not be part of the core, but the last-called plugin (e.g. “99 vSphere Cleanup.ps1”)
Then the framework can be used for non-vSphere plugins in other, vSphere-free) environments.
Three-digit plugin numbers numbered in increments of 10 might be a good idea too.
I’ve tested the concept, and it works perfectly here.
After checking my suggested change to vCheck.ps1, here’s what line 64 should be:
$Plugins = Get-ChildItem -Path $PluginsFolder -filter “*.ps1”
It’s a worthwhile addition.
With it people can put in readme.txt files in their plugins directory, edit the plugins with editors which leave .bak files lying about, or rename plugins to disable them.
@Robert Thanks. That makes it a lot easier.
There seems to be some problem in plugin: 08 Hosts Dead Lun Path.ps1
It doesn’t check for Dead paths and I know I’ve got 2.
The check on line 14 “if ((((Get-View $esxhost).configmanager.StorageSystem).StorageDeviceInfo.ScsiLun |Measure-Object).count -gt 0)”
seems to always be 0 so always fail.
I have no idea what the above is supposed to check so I can’t be any more help and my powershell skills is very limited.
I’m running vSphere 4.1.
@Francois If you unblock the vCheck.zip file before you unpack it, then you don’t have to unblock all the individual files.
Francois, Thanks for this information.
Sybux, I guess so. Thanks for letting me know.
Michael,
Ahh, i did remove that feature didnt I, I will make sure i put it back in 6.1 and also the time it took to run the script, sorry about that.
SomeITGuy, looks like you have an old version of PowerCLI installed, please install the latest and see how it goes.
I got a “Security Warning” error on every script in the plugins directory.
Setting “set-executionpolicy unrestricted” did not help much.
You can right click and “Unblock” each one of them to get them to run.
That’s tedious on 41+ scripts so I downloaded Streams from (http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx) and ran “streams -d *.ps1 on the plugins directory and the base directory.
@Alan, I’ve run the script a second time and now it’s running fine without errors. Was the problem due to first initialization ?
Two things:
1) I typically run the same script (with the same configuration, thresholds, etc) against six different VirtualCenter systems. vCheck5 allowed the name of the system to be passed in as an external parameter like this:
./vCheck5.ps1 vSpherePROD
./vCheck5.ps1 vSphereQA
etc, etc… It seems I need to have multiple configuration files in order to do this now. Or am I missing something obvious? Is there a simpler way to continue my previous method?
2) Would it be easy to include the duration of the script run time in the output of the report? For example, modify the line:
“vCheck v6.0 by Alan Renouf (http://virtu-al.net) generated on WIN-2JMLGHB50FG”
To instead read:
“vCheck v6.0 by Alan Renouf (http://virtu-al.net) generated on WIN-2JMLGHB50FG in 132 minutes”
I think these are both probably fairly easy to do, but I’m not much of a scripting guy, so would appreciate any feedback or advice. Thanks for all your hard work on this fantastic script!
Script runs but I get a lot of errors:
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.
2:37:08 PM Adding Custom properties
The term ‘New-VIProperty’ is not recognized as the name of a cmdlet, function, script file, or operabl
e program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\myname\my documents\scripts\vmware\GlobalVariables.ps1:59 char:15
+ New-VIProperty <<<< -Name PercentFree -ObjectType Datastore -Value {
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
The term 'New-VIProperty' is not recognized as the name of a cmdlet, function, script file, or operabl
e program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\myname\my documents\scripts\vmware\GlobalVariables.ps1:64 char:15
+ New-VIProperty <<<< -Name "HWVersion" -ObjectType VirtualMachine -Value {
+ CategoryInfo : ObjectNotFound: (New-VIProperty:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Get-View : 2/9/2012 2:39:05 PM Get-View Invalid object specified for parameter Id – 'VMHostI
mpl'. Valid types are ManagedObjectReference and string.
At C:\Users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun Path.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDeviceInfo.ScsiLun |Measure-
Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx1.myco.com:VMHostImpl) [Get-View], VimExcept
ion
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.VimAutomation.Commands
.DotNetInterop.GetVIView
Get-View : 2/9/2012 2:39:05 PM Get-View Invalid object specified for parameter Id – 'VMHostI
mpl'. Valid types are ManagedObjectReference and string.
At C:\Users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun Path.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDeviceInfo.ScsiLun |Measure-
Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx2.myco.com:VMHostImpl) [Get-View], VimExcept
ion
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.VimAutomation.Commands
.DotNetInterop.GetVIView
Get-View : 2/9/2012 2:39:05 PM Get-View Invalid object specified for parameter Id – 'VMHostI
mpl'. Valid types are ManagedObjectReference and string.
At C:\Users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun Path.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDeviceInfo.ScsiLun |Measure-
Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx3.myco.com:VMHostImpl) [Get-View], VimExcept
ion
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.VimAutomation.Commands
.DotNetInterop.GetVIView
Get-View : 2/9/2012 2:39:05 PM Get-View Invalid object specified for parameter Id – 'VMHostI
mpl'. Valid types are ManagedObjectReference and string.
At C:\Users\myname\my documents\scripts\vmware\Plugins8 Hosts Dead Lun Path.ps1:14 char:17
+ if ((((Get-View <<<< $esxhost).configmanager.StorageSystem).StorageDeviceInfo.ScsiLun |Measure-
Object).count -gt 0)
+ CategoryInfo : InvalidArgument: (mycoesx4.myco.com:VMHostImpl) [Get-View], VimExcept
ion
+ FullyQualifiedErrorId : Core_GetVIView_TryGetIdParam_InvalidValue,VMware.VimAutomation.Commands
.DotNetInterop.GetVIView
Simplest fix for the disabled plugins issue would be to change vCheck.ps1 line 64 to
$Plugins = Get-ChildItem -Path $PluginsFolder -Include *.ps1
That way, any renamed plugin or editor backup files won’t be included
Alan, I’ve just unzipped and run the script. I’ve entered my vCenter hostname as an FQDN. I know that every time I connect I got a SSL warning (which is quite normal) but the other errors ?
One usecase for disabling plugins is to test new plugins without having to wait for all the good working plugins to finish. 😉
I will go for the disabled plugins folder.
I’m working on converting some extensions that I made to vCheck v5 to plugins. I will mail you the ones that are not specific to our environment, when I’m ready.
Sybux, This looks like an error with the initial connection somehow, did you alter the script manually or just follow the wizard and enter the IP/Hostname of your VIServer ?
Billy, do you have PowerCLI 5.0 installed by any chance ? This was a bug in that version of PowerCLI, it has been fixed in PowerCLI 5.0.1
Maybe create a disabled plugins folder and move it out into there ? I just thought people would delete them to be honest. Why would you want to do this ?
Is there a recommended way to disable a plugin without removing it from the plugins folder? If I rename one of these files to .PS1-DONTRUN it doesn’t run it. But it runs the one above twice. 🙁
Hi Alan
Thanks for a fantastic script, i have been running v5.0 daily for the last few years.
I ran v6 today and in the datastore section the columns for CapacityGB and FreeSpaceGB looked to be the wrong way round.
Thanks again.
Billy
I’ve just discovered your blog some days ago. Last night I’ve received the news about your vCheck. I’ve looked around and find it very usefull. So I’ve downloaded the zip file and run the config. During the process I’ve seen some errors :
09:36:07 Connecting to VI Server
WARNING: There were one or more problems with the server certificate:
* The X509 chain could not be built up to the root certificate.
You cannot call a method on a null-valued expression.
At C:\Users\$heginfo\Desktop\vCheck6\GlobalVariables.ps1:48 char:70
+ $VIVersion = ((Get-View ServiceInstance).Content.About.Version).Chars <<<< (0
)
+ CategoryInfo : InvalidOperation: (Chars:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : InvokeMethodOnNull
09:36:10 Adding Custom properties
09:36:11 Collecting VM Objects
09:36:12 Collecting VM Host Objects
09:36:15 Collecting Cluster Objects
09:36:16 Collecting Datastore Objects
09:36:16 Collecting Detailed VM Objects
09:36:21 Collecting Template Objects
09:36:22 Collecting Detailed VI Objects
09:36:22 Collecting Detailed Alarm Objects
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is nu
ll or empty. Supply an argument that is not null or empty and then try the comm
and again.
At C:\Users\$heginfo\Desktop\vCheck6\GlobalVariables.ps1:85 char:21
+ $alarmMgr = get-view <<<< $serviceInstance.Content.alarmManager
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
09:36:22 Collecting Detailed VMHost Objects
09:36:31 Collecting Detailed Cluster Objects
09:36:31 Collecting Detailed Datastore Objects
09:36:32 ..finished calculating General Information by Alan Renouf v1.0
09:36:35 ..finished calculating Snapshot Information by Alan Renouf v1.0
09:36:36 ..finished calculating Datastore Information by Alan Renouf v1.0
09:36:36 ..finished calculating Map disk region event by Alan Renouf v1.0
09:36:36 ..finished calculating Hosts in Maintenance Mode by Alan Renouf v1.0
09:36:36 ..finished calculating Hosts Not responding or Disconnected by Alan Ren
ouf v1.0
09:36:40 ..finished calculating Hosts Overcommit state by Alan Renouf v1.0
09:36:53 ..finished calculating Hosts Dead Lun Path by Alan Renouf v1.0
09:37:07 ..finished calculating Created or cloned VMs by Alan Renouf v1.0
09:37:08 ..finished calculating Removed VMs by Alan Renouf v1.0
09:37:09 ..finished calculating VMs with over x vCPUs by Alan Renouf v1.0
09:38:41 ..finished calculating VMs Ballooning or Swapping by Alan Renouf v1.0
09:38:41 ..finished calculating Invalid or inaccessible VM by Alan Renouf v1.0
09:38:56 ..finished calculating VMs restarted due to Guest OS Error by Alan Reno
uf v1.0
09:39:04 ..finished calculating HA VMs restarted by Alan Renouf v1.0
09:39:04 ..finished calculating Host Swapfile datastores by Alan Renouf v1.0
09:39:05 ..finished calculating DRS Migrations by Alan Renouf v1.0
09:39:05 ..finished calculating Cluster Slot Sizes by Alan Renouf v1.0
09:39:06 ..finished calculating Guests with less than x MB by Alan Renouf v1.0
09:39:07 ..finished calculating ESXi with Technical Support mode or ESXi Shell e
nabled by Alan Renouf v1.0
09:39:20 ..finished calculating ESXi hosts which do not have Lockdown mode enabl
ed by Alan Renouf v1.0
09:39:20 ..finished calculating Checking VM Hardware Version by Alan Renouf v1.0
09:39:20 ..finished calculating Checking VI Events by Alan Renouf v1.0
09:39:21 ..finished calculating Checking Standard vSwitch Ports Free by Alan Ren
ouf v1.0
09:39:21 ..finished calculating VMs in inconsistent folders by Alan Renouf v1.0
09:39:21 ..finished calculating No VM Tools by Alan Renouf v1.0
09:39:32 ..finished calculating VM Tools Issues by Alan Renouf v1.0
09:39:36 ..finished calculating CD-Roms Connected by Alan Renouf v1.0
09:39:40 ..finished calculating Floppys Connected by Alan Renouf v1.0
09:39:41 ..finished calculating Single Storage VMs by Alan Renouf v1.0
09:39:42 ..finished calculating NTP Name and Service by Alan Renouf v1.0
09:39:43 ..finished calculating VM CPU %RDY by Alan Renouf v1.0
09:39:45 ..finished calculating VM CPU Usage by Alan Renouf v1.0
09:39:48 ..finished calculating Number of VMs per Datastore by Alan Renouf v1.0
09:39:48 ..finished calculating Host Configuration Issues by Alan Renouf v1.0
You cannot call a method on a null-valued expression.
At C:\Users\$heginfo\Desktop\vCheck6\Plugins\36 Host Alarms.ps1:11 char:29
+ $alarms = $alarmMgr.GetAlarm <<<< ($null)
+ CategoryInfo : InvalidOperation: (GetAlarm:String) [], RuntimeE
xception
+ FullyQualifiedErrorId : InvokeMethodOnNull
09:39:48 ..finished calculating Host Alarms by Alan Renouf v1.0
09:39:48 ..finished calculating VM Alarms by Alan Renouf v1.0
09:39:48 ..finished calculating Cluster Configuration Issues by Alan Renouf v1.0
09:39:48 ..finished calculating Datastore OverAllocation by Alan Renouf v1.0
09:39:48 ..finished calculating VCB/Veeam Garbage by Alan Renouf v1.0
09:39:50 ..finished calculating VC Services by Alan Renouf v1.0
09:39:59 ..finished calculating Windows vCenter Error Event Logs by Alan Renouf
v1.0
09:40:02 ..finished calculating Windows vCenter Warning Event Logs by Alan Renou
f v1.0
09:40:22 ..finished calculating VMKernel Warnings by Alan Renouf v1.0
09:40:22 ..finished calculating VMs needing snapshot consolidation by Luc Dekens
v1.0
09:40:22 ..finished calculating Missing ESX(i) updates and patches by Luc Dekens
v1.1
09:40:22 ..Displaying HTML results
I don't know if it's "good" or "bad" but just in case. Of course if you need help to test again, no problem, I'm here.
One other thing, in the report, I get some message in french (which is the language I use), but I'd like to know if it's possible to force to english which is always more understanding 🙂
Thanks you for your really nice and usefull script.
Can you let me know what the errors are please so I can make sure others dont get this. Thanks
If i hardcode the paths it seems to run, other than that I see errors re: the path
Yes, I’ve broken and re-signed the vCheck, globalsettings, and NTP scripts, but now I need only re-run the code signing script (after signing it once)! I’m going to use that thing all over the place.
Good to know, thanks. Now run the script with -config and change something in the wizard, I bet it breaks! You will probably have to sign it only after running through the wizard.
Alan,
Yes, I ran that script on the c:\vCheck6 folder, it signs all the scripts in the vCheck6 folder and the plugins subfolder as well. Thanks for the tip. Note the script needs to have the path changed in two spots.
-Rob
Thanks, this check uses the VMware Update Manager Snapin for PowerShell which is a separate install to PowerCLI, I have updated the plugin to check for this snapin first.
If you dont need that then please delete the check from the plugins folder, if you do want it then please download the VMware Update manager snapin from here: http://www.vmware.com/support/developer/ps-libs/vumps/
Make sure you download the correct version depending on your Update manager Version, the Update Manager snapin is not backward compatible.
New version: Get the error:
The term ‘Get-Compliance’ is not recognized as the name of a cmdlet….
Any ideas?
RobVM,
Thats a good point – I didnt think of that did I, I wonder how it will work with the config too as that edits the file.
I spotted this, does it help ? http://serveranalyst.wordpress.com/2011/11/12/code-signing-multiple-powershell-scripts/
Thanks for all your hard work, Alan. simply the best Powershell script out there for VMware.
Generally I sign the vCheck script before I run it. But now I have all these plug-ins. Is there a command I can add to the Set-AuthenticodeSignature cmdlet to sign every plugin in the plugins folder? I know there must be an easy way, something like Get-Childitem *.ps1
Pingback: vCheck 6.0 released
Pingback: vCheck 6.0 est disponible
—– VCHECK 6 RELEASED —–
is It possible to have the Script to check Cluster compliance (HA/DRS) such as the Host Isolation Response setting. The reocommended Host Isolation Response setting is “Leave Powered on” so that the VM will be powered on when host failure occurred. It will be good if the script is able to verify this settings.
Thanks for the excellent script — is there a way to pull annotations from the hosts which are in maintenance mode?
Fred, Yes the dvSwitches dont have that property, I have changed this check in v6 to only look at standard groups, maybe another check will do the work for dvSwitches.
at vSwitch Ports Check section my report is showing all my dvSwitches and at column “ports left” there are no values.
Thanks Alan ! $ntpserver = “10.10.10.80|10.10.10.85″ working fine!
At hardware version check section i had several VM´s listed although the report shows they are already on hardware version 8
I changed Where {$_.HardwareVersion -ne “Version 7”} to Where {$_.HardwareVersion -ne “Version 8”}
Fred use “10.10.10.80|10.10.10.85”
I have 2 ntp servers:
10.10.10.80
and
10.10.10.85
How should i define the $ntpserver ?
All charts are blank. Other info seems to be there. Any idea why charts are blank? I am using Office 2010.
Thanks,
Morrisos
So the Creator portion of the Snapshots section is coming up blank since using this on vCenter 5 and PowerCLI 5. Is anybody else experiencing this and if so, is there are fix?
Hi guys, i am new all to script, I have heard every one speak highly of this one, I have downloaded, but it is not working!! Please help, if any one got one with all these nice update I would much appreciate it
Great script. have an issue where the output report has doubled everything. We have 9 hosts in one environment and the report finds 18 hosts? Any ideas??
Thanks
No, use “email1@me.com”, “email2@me.com”, “email3@me.com”
if i wanted to send the report to multiple emial addresses without crating a whole distribution group for it. can i simply do this?
$EmailTo = “IT@yyyy.com; lpalacio@yyyy.com”
Thank you
hello,
the capacity planner for CPU on one datacenter is misreporting a negative number of available VMs since we restarted all nodes in the datacenter. Can anyone point me at what might be causing this / where in the script this is defined?
ta
martin.
For some reason it is only showing linux guest with < 100mb of space left. It is not showing windows guest with , 100mb of space when I do indeed have a few. Is there something I am doing wrong with it perhaps?
Hi Alan
very nice script – thanks a lot for sharing
I got one question …
I configured the script so that it only monitors the really serious issues.
What can I do so that it does not send an email when none of the tables is populated and instead just silently exits ?
just wanted to know, will this script work while providing multiple vCenter IPs…??
.\vCheck5.ps1 vCenter01 vCenter02 vCenter03
This is really some script.. great effort put into it.. and that shows.. awesome work guys… !!!
cant wait for more
Hi – I’m using vCheckv5 and have noticed that while under the General Details section there are 7 clusters reported (and a Get-Cluster from PowerCLI also shows 7 clusters) the vCheckv5 report only shows Capacity Planner Info for 4 clusters.
Anyone else seen this issue?
I have to produce monthly uptime report of all esxi hosts. can we get the same with this script.
Hi – I am finding vCheckv5 is incorrectly flagging HW v8 as old in the “VMs with old Hardware” section.
Easy enough to fix to support vSPhere new HW v8 –
thanks as always
@Alan (and @slaclair)–
I have a version of the script with all of the depreciated properties fixed if you’d like me to send it. I did a find and replace on all the occurrences of Host and State until the script ran without throwing up any warnings – there were quite a few. I then grabbed a fresh copy from the site and merged in those changes.
Figured it might save you some time.
Hi Al – love your script. I’ve made a few modifications to your script to fit my environment, but this makes updating to new versions difficult.
Would it be possible to add a section for identifying VMs that are not @ a particular memory reservation level?
As a VSPP, I get charged for memory reservation which must be a minimum of 50% of Allocated RAM. The addition of VMs configured with zero reservation or @ more than 50% of allocated would eliminate my need for a separate script.
Thanks for the great tool!
hi Virtu-Al ,
is it possible that we can export report generated by vcheck 5 into excel, if yes kindly guide how it can be done.
This is fantastic art of work! Just wanted to add something I noticed, if there are lot of ESX hosts in the cluster the “LUN check” part of this report is not clearly visible. The LUN naa.ID’s overwrites the coloumns and it becomes messy. Is there any way to put a slider to move it to right. thanks.
Hi Al,
I want to be able to see what VM’s have updated tools, I have tried a few bits of code but want to add it to this script. Can you help?
Luke,
Yep should do, works fine on mine. Let me know if you hit any issues.
Does this work fine on ESXi 5 vcenter.
As I could do with this?
Cheers
Luke
Thanks, I know about the warnings, need to fix that in a future version.
Pingback: VMware support documentation and 3rd party tools list « Cavarpe Technology Blog
Upon executing I get warnings for depreciated properties, no deal breakers but items I figured it couldn’t hurt to bring to your attention for future releases.
WARNING: ‘State’ property is obsolete. Use ‘ConnectionState’ instead
It looks like it’s coming from the $MaintHosts =@ line (I currently have it open in notepad so I can’t get you a real line count at the moment.)
Also
WARNING: ‘Host’ property is obsolete. Use ‘VMHost’ Instead
which appears to be coming from the $BALSWAP line
Not a deal breaker, just something to look into
>> It has ben suggested to us to have a limit
>> of 30 VMs per host in our environment as a
>> best practice.
Let me guess – a hardware manufacturer made that suggestion? # of guest VMs is one of the last things I would measure. You are virtualizing your guest OS’s to better utilize your hardware (among other things) why would someone claim X number of VMs should be the best practice without examinging load and resources used. 30 of one type of guest on one type of host would be way too many … 30 of another type of guest on another type of host would be way too few. Can’t just throw out a number. Someone wants to sell more hardware.
Thanks for the timings, this is useful when looking at areas to optimize for future versions.
Puh it takes about +12 hours to complete – is that normal?
20:50:15 Collecting VM Objects
20:50:18 Collecting VM Host Objects
20:50:21 Collecting Cluster Objects
20:50:21 Collecting Datastore Objects
20:50:22 Collecting Detailed VM Objects
20:50:32 Collecting Template Objects
20:50:33 Collecting Detailed VI Objects
20:50:33 Collecting Detailed Alarm Objects
20:50:34 Collecting Detailed VMHost Objects
20:50:42 ..Adding General Summary Info to the report
20:50:49 ..Checking Capacity Info
21:16:28 ..Checking Snapshots
08:37:33 ..Checking Datastores
08:37:33 ..Checking for Map disk region event
08:37:33 ..Checking Hosts in Maintenance Mode
WARNING: ‘State’ property is obsolete. Use ‘ConnectionState’ instead.
08:37:34 ..Checking Hosts Not responding or Disconnected
08:37:34 ..Checking Hosts Overcommit state
08:37:46 ..Checking Hosts Dead Lun Path
WARNING: ‘LunPath’ property is obsolete. Use ‘Name’ instead (it holds the same
value).
08:39:02 ..Checking for created or cloned VMs
08:39:28 ..Checking for removed VMs
08:39:30 ..Checking for VMs with over 2 vCPUs
08:39:30 ..Checking for VMs swapping or Ballooning
WARNING: ‘Host’ property is obsolete. Use ‘VMHost’ instead.
08:43:30 ..Checking invalid or inaccessible VM
08:43:30 ..Checking HA VM reset
08:43:38 ..Checking HA VM restart
08:43:45 ..Checking Host Swapfile datastores
08:43:45 ..Checking DRS Migrations
08:43:52 ..Checking Cluster Slot Sizes
08:43:54 ..Checking for Guests with less than 10 MB
08:43:55 ..Checking for ESXi with Technical Support mode enabled
08:44:21 ..Checking for ESXi hosts which do not have Lockdown mode enabled
08:44:32 ..Checking VM Hardware Version
08:44:32 ..Checking VI Events
08:44:39 ..Checking VMs in Inconsistent folders
08:44:39 ..Checking VM Tools
08:44:39 ..Checking VM Tools Issues
08:48:58 ..Checking for connected CDRoms
08:50:04 ..Checking for connected floppy drives
08:51:11 ..Checking Datastores assigned to single hosts for VMs
08:51:14 ..Checking NTP Name and Service
08:51:20 ..Checking VM CPU %RDY
08:55:09 ..Checking VM CPU Usage
09:19:45 ..Checking Number of VMs per Datastore
09:19:50 ..Checking Host Configuration Issues
09:19:50 ..Checking Host Alarms
09:20:05 ..Checking VM Alarms
09:20:05 ..Checking Cluster Configuration Issues
09:20:05 ..Checking VC Services
09:20:06 ..Checking VC Error Event Logs
09:20:18 ..Checking VC Warning Event Logs
09:20:26 ..Checking VMKernel Warnings
09:20:43 ..Displaying HTML results
09:20:44 ..Sending Email
PowerCLI C:\it\vmware>
Pingback: Episode 166 – Alan Renouf talks PowerCLI « PowerScripting Podcast
Is is possible to list how many VMs per host? It has ben suggested to us to have a limit of 30 VMs per host in our environment as a best practice. The script is great!
Pingback: VMware vCenter Server Active Directory Web Services LDAP error on instance ADAM_VMwareVCMSDS « Yuri's Technology Blog
Has anyone been able to exclude VMs from sections such as VMtools, CPU Ready?
In VC we have a test cluster that suffers from lack resources and VMtools issues we’d rather not report on in vCheck.
great script.
Would love to see a check on objects that have alarm actions disabled.
Is there a way to display the machine name and OS version by what datastore it belongs to? That would be nice addition to the report (at least I think it would be ) 🙂
I think this would be helpful for folks that have a san that is cable to do perform deduplication on the datastores. If all virtual guests with same os version would belong in the same datastore this would greatly be a benefit for a deduplication thus getting storage space back. So syaing that if it was possible to list that then the admin can sprinkly the machines around to in the datastores accordingly.
just a thought.. Perhaps a oneline command of sorts?
Awesome script, already tweaked it a bit for our environment.
One of the things im working on, though my posh’s isnt as clean as yours.
-checking ESXi hosts for central logging enabled, and if not then displaying whatt local datastore is keeping the logs.(working on it)
-Printing report directly to sharepoint (done)
-find “NUMA” violators/problem VMs (not started)
-how many smotions happen over a time period (not started)
-Identify Luns using Fixed PSP (not started)
Hi, have a question about the script.
Does the VMs Created or Cloned (Last x Day(s) only show per month ?
Cause i need a report of the previous month
so on the last day of the month i collect with the script, but there is now info about created, removed vm’s in the list 🙁
i have set it to the last 30 days to look for.
And there where creations and deletion of vm’s in that month.
Great Script, makes the daily checks thorough and consistent. Another nice feature could be to show a summary of VM Guest disk types: thin, thick. For our environment we thick everything on the VM side (SAN Array side it varies), so sometimes VM admins will create a thin disk not knowing. So this would essentially catch those configuration inconsistencies.
The NTP-check always lists every host – but NTP-server is always correct and service running.
Has anybody encountered that problem?
Thx
tranquilo
Hey Dan D (August 23, 2011)
super schedule setup, Thanks 🙂
I’m trying to run the script from my workstation to a vcenter server which is located on another non-trusted domain and I always get asked to provide user/pass (and then I can’t automate it with a scheduled task).
I’ve provided the other domain’s credentials inside the script, but that didn’t help.
Is there a way to achieve this?
BTW – Great script, love it!
Hi
In line 1120 rember to change “Version 7” to “Version 8” if you are using vSphere 5.0.
Pingback: Nice vSphere test / report script
It’s running 🙂
Hey
Can’t make the script run!
error:
File C:\temp\vCheck5.ps1 cannot be loaded. The file C:\temp\vCheck5.ps1 is not
digitally signed.
@ChrisSB
I think I have a workaround that can fix the issue you are seeing in Outlook. If you find the line that looks like this:
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV $MyReport
And change it a bit to look like this:
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV $MyReport.Replace(“class=`”dsp “,”class=`””)
One of the style sheet headings will be removed in the email before it goes out. Outlook doesn’t properly render nested style sheets which causes this problem. The emailed output doesn’t look as good as the HTML file that is created, but it is much better than what you are seeing now.
Hope it helps!
@bwuch
Hi All,
Running Version 5.0
Issue with Get-CustomHeader
In Outlook its not displaying the Title or comments in the report. Any idea on what needs to change to correct this?
And as it stands, the whole format and font layout is completely off in Outlook. I understand that this is most likely an M$ related issue in how Outlook’s HTML interpriter is defined, but I’m hoping that someone has tackeled this.
Thanks,
Chris
getting Access Denied when the script is checking the following
VC Error Event logs
VC Warning event logs
VC Services
I’m even getting this Access Denied message with an account with full domain privilege
Hi,
I tried this script and ran into some truoble. I updated the smtp IP and the username/credentials. But when I run the script its just exists without showing any output.. The only output i receive is as given below (I am running the script from the VCenter Server itself – that is why I use the loopback IP – I tried with using the FQDN and the IP as well but same results):
PS C:\Users\admin\Desktop\PowerCLI Scripts> .\vCheck5.ps1 127.0.0.1
5:01:50 AM Connecting to VI Server
PS C:\Users\admin\Desktop\PowerCLI Scripts>
Can someone help me to find out whats wrong?
Please could some explain what “VM with mismatch power custom fields/powerstate” is supposed to mean.
All my VM’s are listed in this section.
User column for Snapshots and VMs created, cloned and removed are blank on my reports. A bit of digging and I can see that the VIEvent.username property is set to “User” and not the actual username that created the VM, e.t.c.
This was working. Not sure what has changed, I thought it might have been an upgrade from PowerCLI 4.1 to PowerCLI 4.1.1 but I have just uninstalled 4.1.1 and reinstalled 4.1 but still can not get the username from the VIEvent object.
hi, use your script for reporting and i love it !
I only miss some things:
– patch levels (which patches installed) from esx server
– CPU usage per esx server
– MEM usage per esx server
Is this simple to modify in your script ?
Hi Alan, thanks for the script, it works great.
I found it inconvenient that mem.swapped only gives you a high water mark – the same value every day. Since I can’t reboot servers every time they swap to reset the swapped value I changed the script in the VMs Swapping or Ballooning section to:
(Get-Stat -Entity $_ -Stat mem.swapoutRate.average -Start (get-date).AddDays(-1) -Finish (get-date) -ErrorAction SilentlyContinue | measure-object value -max).Maximum
This shows me if a VM has actually swapped during the last 24h.
Just wanted to share that.
Regards
Tranquilo
It is PowerCLI 5.0 you need, what are the errors you are getting ?
Where can I get PowerCLU? I am running PowerCLI 5.0 and just get a ton of errors when I try the script as I cant find a download of PowerCLU for PowerCLI 5?
No, I dont write SQL scripts.
Do you have any SQL script which can tell how many time VM was powered on in last 30/60/120 days?
Looks like I was using the wrong function. Using the following basic cmdlet worked perfectly fine when trying to shutdown a VM with a specific value in a custom field:
Get-VM | where {$_.CustomFields[“ShutdownDaily”] -eq “Yes”} | Shutdown-VMGuest -Confirm:$false
Hope this helps anyone else wanting to do this.
Pingback: Mellquist.dk » Blog Archive » vCheck – VMware vSphere monitoring and reporting
The download should now be re-available again – sorry for the delay,
good luck with your restore, alan and thanks for the script!
i hope this version is not too old?
http://web.archive.org/web/20101110085412/http://virtu-al.net/Downloads/vCheck/vCheck5.ps1
Still working on restoring my site after a hack.
Keep getting File Not Found when trying to download.
Not able to get the Linux VM’s server information
Excuse me, I got a found not found error. Is the script still available?
Seems the download isn’t working. I would love to try the script out though 🙂
I’ve created a Get-CustomField function to output certain VMs with a specific value in a custom field:
function Get-CustomField {
param($item)
foreach ($cf in $item.CustomFields) {
if ($cf.Value) {
$field = “” | Select Key, Value, EntityName
$field.key = $cf.Key
$field.Value = $cf.Value
$field.EntityName = $item.Name
Write-Output $field
}
}
}
Get-VM | Foreach { Get-CustomField $_ } | where {$_.value -eq “test”} | Out-GridView
Now I would like to shutdown or start up these VMs with these values by using “Stop-VM” and “Start-VM” but it returns “The input object cannot be bound…” error. Is this possible using this function?
NOT SHOWING VM’s ADDED and REMOVED?
Hey Guys,
The feature to show vm’s added and removed used to work. When I reinstalled my workstation and re-downloaded the script I am finding the other report functionality works correctly but it will not report on vm’s added or removed in X days. I have it set to 10. I’m not sure if this is somehow related to our VC setup or something in the script I am doing incorrectly.
Any ideas?
@jaap,
Could you try running the following code from a powershell window to see if you get the email message? You’ll need to change the SMTP password, server, to/from addresses and the mydomain\username:
$smtpPassword = “MySmtpPassw0rd” | ConvertTo-SecureString -asPlainText -Force
Send-MailMessage -SmtpServer “smtp.mydomain.local” -From “test@mydomain.local” -To “me@mydomain.local” -Body “This is a test” -Subject “TEST” -Credential (New-Object System.Management.Automation.PSCredential(“mydomain\username”,$smtpPassword))
If it works I can walk you through using the Send-MailMessage cmdlet in your existing vCheck script.
Well, it took me a little while to get this to actually run, but its golden. Running this on my VC right now and hoping for some good detailed info. Still dont see graphs though…. : /
Hi
I realy like your script, but sending mail doesn’t work for me, i need autehntication
i have the following
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$mailer.Credentials = New-Object System.Net.NetworkCredential(“xxxxxx@xxx.xxx”, “xxxxxxxx”);
$msg.IsBodyHTML = $true
$mailer.send($msg)
}
# Set the SMTP Server address
$SMTPSRV = “xxxx.xxx.xxx”
# Set the Email address to recieve from
$EmailFrom = “xxxxxx@xxx.xxx”
# Set the Email address to send the email to
$EmailTo = “xxxxxx@xxx.xxx”
I don’t have any experience with scripting, so i guess i do something wrong
btw sendmail is true
Regards
Jaap
@bwuch
Nevermind i found it 🙂
@bwuch
Nice, thanks, but how can i say where the file must go ?
@c0de1,
Comment the following lines by prefixing them with a # sign
Line 1562 = #if ($DisplayToScreen) {
Line 1569 = #Invoke-Item $Filename
Line 1570 = #}
This will cause the script to export the file but not Invoke (open) the report.
Hi,
is it possible in a very simple way to let the output not go the screen or email but to a file on a specific location?
love your script !
can u add vmkuptime.pl report in the vchek
Finally got this to run as a scheduled task, using local user account on Win2008R2. I also had the problem where it only reports 1 host.
Changed the Connect-VIServer line to:
$VIServer = Connect-VIServer $VISRV -cred $creds
Changed the $SetUsername line to:
$SetUsername = “Computer\localuser”
Changed $CredFile line to:
$CredFile = “C:\vCheck_Reports\vc_cred.txt”
Pre-created the directory listed for CredFile, but do NOT create the file.
Run the script as the user referenced as $SetUsername, it will prompt you, enter the name and password. Should be good to run as a task.
Note that I cheated on a couple of things.
first, I commented
param( [string] $VISRV)
and configured the vcenter in the config section
$VISRV = “vCenter.domain.loc”
second, I added this line right after the “Start of script” line:
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
Now my Task command is: powershell.exe
and for arguments:
-File “C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\vCheck5.ps1”
Hopefully that saves somebody some time!
Couple of things I’ve noticed/modified (some already mentioned):
— Missing reporting variables
# Show overallocated datastores
$ShowOverAllocation = $true
# Show VCB snapshots left over
$ShowVCBgarbage = $true
— The email as attachment changes mentioned by someone above = perfect
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 = new-object Net.Mail.Attachment($attachment)
$msg.attachments.add($attachment)
$mailer.send($msg)
}
…
# make sure DisplayToScreen is set to $true also
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV “vCheck report for $VISRV is attached” $Filename
— Added checking for out-of-date tools in the $ShowTools section
$NoTools = @($FullVM | Where {$_.Runtime.Powerstate -eq “poweredOn” -And ($_.Guest.toolsStatus -eq “toolsNotInstalled” -Or $_.Guest.ToolsStatus -eq “toolsNotRunning” -Or $_.Guest.ToolsStatus -eq “toolsOld”)} | Select Name, @{N=”Status”;E={$_.Guest.ToolsStatus}})
— changed the VM disk space section to work on a percentage, not static size. One key thing (for this change and current code checking disk size in MB) is to re-sort the list after building before adding to report, as there is a bug with out-gridview and Get-HTMLTable when the first PSObject has less properties than later ones. Example of the code I use for percentage checking and the resorting is:
# —- VM Disk Space – Less than x % —-
If ($ShowGuestDisk){
Write-CustomOut “..Checking for Guests with less than $PercFreeLimit %”
$MyCollection = @()
$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq “poweredOn” -And ($_.Guest.toolsStatus -ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne “toolsNotRunning”)}
$SortedVMs = $AllVMs | Select *, @{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
ForEach ($VMdsk in $SortedVMs){
$Details = New-object PSObject
$DiskNum = 0
Foreach ($disk in $VMdsk.Guest.Disk){
if ($disk.Capacity -ne 0){
$PercFree = ([math]::Round((($disk.FreeSpace / 1MB)/($disk.Capacity/ 1MB))*100))
} else {
$PercFree = 0
}
if ($PercFree -le $PercFreeLimit){
$Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty
$Details | Add-Member -Name “Disk$($DiskNum)path” -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name “Disk$($DiskNum)Capacity(MB)” -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1MB))
$Details | Add-Member -Name “Disk$($DiskNum)FreeSpace(MB)” -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
$Details | Add-Member -Name “Disk$($DiskNum)%Free” -MemberType NoteProperty -Value $PercFree
$DiskNum++
}
}
if (($Details | get-member -membertype properties) -ne $null) {
$Details | Add-Member -Name “ViolatingDiskCount” -MemberType NoteProperty -Value $DiskNum
$MyCollection += $Details
}
}
If (($MyCollection | Measure-Object).count -gt 0) {
$MySortedCollection = $MyCollection | Sort-Object -Descending ViolatingDiskCount | Select * -exclude ViolatingDiskCount
$MyReport += Get-CustomHeader “VMs with less than $PercFreeLimit % Free Space : $($MyCollection.count)” “The following guests have less than $PercFree % Free, if a guest disk fills up it may cause issues with the guest Operating System”
$MyReport += Get-HTMLTable $MySortedCollection
$MyReport += Get-CustomHeaderClose
}
}
Script is excellent though, can’t wait for 5.1
@Robert,
Cmdlet works great, but when I added it to my report none of the object names are displayed under their specified headings. It shows “Object.System[]”. Any further help adding this in the report will be greatly appreciated.
Thanks.
@Kenny, you can get the VM name also with:
Get-VM | Get-NetworkAdapter | Select-Object -Property @{N=”VM”;E={$_.Parent}},
Name,Type,NetworkName,MacAddress,WakeOnLanEnabled
hey guys,
i’m trying to run this script as a scheduled task with a service user instead of my personal admin. scheduling works great acutally, but for some reason when i run the script with the service user, it keeps asking me for credentials at the following points:
– “..Checking VC Services”
– “..Checking VC Error Event Logs”
– “..Checking VC Warning Event Logs”
Even when i manually type in the credentials of the service user when promted, it seems that the service user is not able to capture those information. The service user has local admin rights on the vCenter server and administrator rights within vCenter (propagated).
What am i missing? thanks for your help!
Like clock work, I run this script regularly especially after adding the “LastPowerOn” section. Now however I am attempting to add a section naming the VMs and their current network adapter types. I am using this cmdlet “Get-VM | Sort Name | Get-NetworkAdapter”, but it does not display the VM name. Are there other cmdlets to produce these results?
@Jorge Cruz,
It doesn’t appear that I have any duplicate UUID’s in my environment, but I think the following code would show you all of the duplicates:
$vmview = Get-View -ViewType VirtualMachine | Select @{Label=”VM Name”;Expression={$_.Config.Name}},@{Label=”VM UUID”;Expression={$_.Config.Uuid}}
$vmview | Group-Object -Property “VM UUID” | Where-Object {$_.Count -gt 1} | %{ $myObj += $_.Group }
$myObj | Sort “VM UUID”, “VM Name”
Please let me know if it works out!
Thanks,
@bwuch
Hello, excellent script, very good.
I need a validate a UUID VM conflict (two o more VM with same UUID) … please review this feature report in next version …
thks
@wayvirtural,
I had a problem sending mail from PowerShell at one point, but turned out to be a policy my antivirus guy had pushed down to prevent mass mailing worms. You can try this from a powershell window to see if you have a similar restriction:
Send-MailMessage -SmtpServer “smtp.hello.com” -From “admin@hello.com” -To “test1@hello.com” -Subject “Test message” -BodyAsHtml -Body “This is a test message.”
If you a message like this: “Send-MailMessage : Unable to connect to the remote server” you may have something like that going on too.
Great script and thanks for sharing. however I am stuill unable to receive email. I can run the script and see the results on the broswer but just cant get email. Please Help!
# Set the SMTP Server address
$SMTPSRV = “smtp.hello.com”
# Set the Email address to recieve from
$EmailFrom = “admin@hello.com”
# Set the Email address to send the email t
$EmailTo = “test1@hello.com”
# Use the following item to define if an email report should be sent once completed
$SendEmail = $true
# Use the following item to define if an email report should be sent once completed
$SendEmail = $true
if ($SendEmail) {
Write-CustomOut “..Sending Email”
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV $MyReport.Replace(“class=`”dsp “,”class=`””)
}
Pingback: Encrypt powershell Credentials (creds) files - Admins Goodies
@c0de1, I don’t believe the code is setup to limit reporting to a single datacenter. However, I have seen someone mention a clever work around that might help. If you create a user account that only has permissions to a single datacenter, and then run the vCheck using that account it will only include results from the datacenter it has permissions to read. Hope this helps!
Hi, love your work !
Is it possible to only make a report of a particulair datacenter?
because we have multiple datacenters on out farm
Pingback: Virtu-Al | Virtually everything is poshable
@Virtu-Al, I actually stumbled across that script already, and have had a play with it… finally got it to somewhat work, using the 32bit version of the PowerCLI run time, and it was producing graphs….
Wont look at code too much, although I am a newbie to PS, so will look ok to me LOL
You know what management are like, they want all the fluffy management reports, with pretty pictures ohh and of capacity predictions without the costs. So if I can automate something with powercli, powershell and the like then it gives me a nice missions on cutting my teeth with the whole environment.
@Matt,
You may also want to check out one of the first scripts I wrote (just dont look at the code 😉 here:
http://www.virtu-al.net/2008/08/15/exporting-virtual-infrastructure-information-to-ms-word/
And also if its a visio diagram make sure you check out the VMware PowerPack for PowerGUI which offers this for free and is based on this original script: http://www.virtu-al.net/2009/01/26/vdiagram-draw-your-vi-with-one-script/
@Matt – you may want to check out veeam reporter, there is a free version of the tool that will suffice. It will also provide you with a visio diagrams of the infrastructure.
@simon, this is why I am asking the questions, to find out if this tool is not suitable, what other options may be out there to get “graphical management reports” obviously without the cost associated with them.
And you could go down the openxml document format for office 2007, that way you only require the framework to be installed I am led to believe?
@matt – Why would you want that ? Its not that type of report really – its for people who support the environment. It would also mean people having to install office etc on whatever servers they use to monitor the environments.
There are all kinds of tools for doing graphical management reports but this is a daily health check…
Hey there, just wondering if there was any plans to make this write to a word doc or PDF form? and maybe adding some charts and stuff in? I know from a management point of view, they like the pretty pictures 🙂
If you dont ask, you dont know right?
@Bwuch.
Thanks that did the trick. I was missing this important piece ($Filename)
@Pete L,
This is a two part deal. Between lines 243 and 244 (right after “$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)”) you’ll want to add something like this:
$attachment = new-object Net.Mail.Attachment($Filename)
$msg.attachments.add($attachment)
This makes sure the file is attached to the email when it is sent. You’ll also need to make sure that the file you want to attach is actually created (normally only happens if $DisplayToScreen is set to $true, which you may not want for a scheduled task). You could also verify this happens if around line 1571 (right above the “if ($SendEmail)” line) you add code like this:
$Filename = “C:\tmp\” + $VIServer + “vCheck” + “_” + $Date.Day + “-” + $Date.Month + “-” + $Date.Year + “.htm”
$MyReport | out-file -encoding ASCII -filepath $Filename
This will cause the Out-File command to execute even if the $DisplayToScreen is not enabled. The file will be created anyway — and then it will be available to attach to your message.
Hope this helps!
I found it down the bottom of the script.
Great script. Is it possible to direct the output to a html file?
run the script in a scheduled task that would essentially do this :
vcheck5.ps1 myvcenter > myventer.html.
This is different than the result just popping up in a new html window. I’d want this to run unattended while logged out. Then another script would ftp the myvcenter.html file up to an internal web site. Do this for all my vcenters and in this central web site, I’d have a dashboard where I could see today’s report for each vcenter. So all I need is for the html output to go to a file.
thanks
Roger
#BUMP#
I tried the file attachment changes mentioned to send the report as an attachment. Upon completion I would receive an embedded email report but no attachment.
Any one else?
hints? things to check?
Al,
What can I say! You are a God amongst Men. I have been using this excellent script since version 2 (I Think?)
However, I feel I must point out an issue I am experiencing with the section reporting Triggered Alarms for VMs and Hosts. I ran your report which reported that there were no VMs with triggered alarms but later found that there were by trawling the VIEvent log. It seems to be that I (and maybe others) am experiencing a bug in PowerCLI (since your logic looks faultless to me).
Your section is:
# —- VM Alarm —-
If ($ShowVMAlarm){
Write-CustomOut “..Checking VM Alarms”
$vmsalarms = @()
foreach ($VMView in $FullVM){
if ($VMView.TriggeredAlarmState){
$VMsTriggeredAlarms = $VMView.TriggeredAlarmState
Foreach ($VMsTriggeredAlarm in $VMsTriggeredAlarms){
$Details = “” | Select-Object Object, Alarm, Status, Time
$Details.Object = $VMView.name
$Details.Alarm = ($valarms |?{$_.value -eq ($VMsTriggeredAlarm.alarm.value)}).name
$Details.Status = $VMsTriggeredAlarm.OverallStatus
$Details.Time = $VMsTriggeredAlarm.time
$vmsalarms += $Details
}
}
}
However:
$VMsTriggeredAlarm.alarm.value does not return any values nor indeed if you reference any property under $VMsTriggeredAlarm directly. Using $VMsTriggeredAlarm | fl * works though and $VMsTriggeredAlarm | gm shows the properties but direct reference does not work ?!?!?!?!?!?
The only way I could get this to work was to perform a select on $VMsTriggeredAlarm to get access to the alarms and then your logic worked. BIZZARRE!!!
The code I got to work is:
# —- VM Alarm —-
If ($ShowVMAlarm){
Write-CustomOut “..Checking VM Alarms”
if(!$alarms){
$alarms = $alarmMgr.GetAlarm($null)
$valarms = $alarms | select value, @{N=”name”;E={(Get-View -Id $_).Info.Name}}
}
$vmsalarms = @()
foreach ($VMView in $FullVM){
if ($VMView.TriggeredAlarmState){
$VMsTriggeredAlarms = $VMView.TriggeredAlarmState
Foreach ($VMsTriggeredAlarm in $VMsTriggeredAlarms){
$Details = “” | Select-Object Object, Alarm, Status, Time
$Details.Object = $VMView.name
$Details.Alarm = ($valarms | where{$_.value -eq (($VMsTriggeredAlarm | select alarm).alarm.value)}).name
$Details.Status = ($VMsTriggeredAlarm | select overallstatus).OverallStatus
$Details.Time = ($VMsTriggeredAlarm | select time).time
$vmsalarms += $Details
}
}
}
Have you seen this before or is this just me ?
I’d appreciate your thoughts as this seems bonkers to me!
Keep up the great work.
I have come back to using vcheck5.3 after a couple months of not. I am finding now however that the vm’s removed/cloned/created is not reporting. This used to work and all other stats appear to show correct information on the report.
Any ideas?
@bwuch
One word… – Brilliant!
It worked like a bomb, not one glitch. I’m sure the code you gave would help many others that were looking for these type of results.
Again, thank you very much. (***tipping my hat***)
@bwuch,
Any chance of incorporating the following code to allow for authenticated relay on smtp
Add
$SmtpUser = “servername”
$SmtpPass = “password”
Modify the Send-SMTPmail function to look like
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$mailer.Credentials = [System.Net.NetworkCredential]::($smtpusername, $smtppassword)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$msg.IsBodyHTML = $true
$mailer.send($msg)
}
Thanks
@Thomas M,
I did something around what you are looking for a little while back.
Have a look here http://www.virtu-al.net/contact-me/ for my entry dated March 16th, 2011 – 12:11 item no 2
Basically it was based on a percentile usage. let me know if that helps, code is a bit rough but should work.
We use it along with the normal capacity planning stats to come up with a more accurate guess
Thanks
@Pete L,
As a former storage admin, I can confirm that we never have problems with LUNs — the problem is always with the app owner 🙂 Anyway, the Dead Luns section shows dead paths between ESX and the LUN. This may not indicate a LUN issue and could show up if you have storage removed from your environment — the ESX host is looking for a LUN that no longer exists and assumes it is dead. In the past I have re-scanned HBA’s and had this error disappear.
@Thomas M,
The capacity section is calculated based off of statistics and HA fail over requirements. The numbers estimate the number of virtual machines you could run, under average load, accounting for your HA failover level. The numbers do not account for peak operation and I doubt you could actually run that number of virtual machines in your cluster — but it is pretty good in terms of a rough estimate.
@Kenny,
The code provided here (http://blogs.vmware.com/vipowershell/2009/10/when-was-the-last-time-that-vm-was-powered-on.html) is a function. For it to return anything, you’ll need to give it a VM object. For example you could run Get-VM | where {$_.PowerState -eq “PoweredOff”} | Get-LastPowerOn
If you add the function into the vCheck and include something like the following code block, you should get a section that shows you what you are interested in:
$guestDownTime = @()
$vm | where {$_.PowerState -eq “PoweredOff”} | %{
$Details = “” | select VM, PowerState, LastPowerOn, DiskGB
$Details.VM = $_.name
$Details.PowerState = $_.PowerState
$Details.LastPowerOn = Get-LastPowerOn $_
$Details.DiskGB = [math]::round($_.UsedSpaceGB, 2)
$guestDownTime += $Details
}
if (($guestDownTime |Measure-Object).count -gt 0){
$MyReport += get-customheader “Powered off VMs : $($guestDownTime.count)” “The following VMs are currently powered off and could possibily be relocated to slower storage or deleted if no longer required. The date/time of the most recent power on task is included for reference.”
$MyReport += get-htmltable ($guestDownTime | sort LastPowerOn)
$MyReport += Get-CustomHeaderClose
}
}
Nevermind. It was the way I jacked with the script to ‘discover my hosts’
Get-WmiObject -Computer MyDomainController -Namespace “root\MicrosoftDNS” -Class “MicrosoftDNS_AType” `
-filter “ContainerName=’prod.mydomain.com'” | Select-Object ownername | where-Object {$_.ownername -like “*irv-dev-esxi*”} | Select Ownername |`
foreach-object{
$VISRV = Connect-VIServer $server -credential $creds
}
I had put this before the functions so the ‘if ($VISRV -eq “”)’ didn’t fail. I guess powershell requires functions to be listed before they are called as opposed to vbscript since its not compiled at runtime?
Has anyone gotten this to work without vCenter? I have 10 ESXi hosts and have no problem enumerating them via a DNS query, but when I go to connect, I either have to use
Connect-ViServer -username -password, or I get prompted. If I try-
$SetUsername = “root”
$CredFile = “c:\data\dev\powershell\root.crd”
$VISRV = Connect-VIServer $server -credential $creds
I don’t get prompted (and it doesn’t work)
Other than that, this is pretty frickin sweet for what I am trying to do, and I have been able to add other tables to give me a full breakdown of my environment.
Any thoughts?
@Bwuch
I came across this link (http://blogs.vmware.com/vipowershell/2009/10/when-was-the-last-time-that-vm-was-powered-on.html) while I tried to incorporate this section in vCheck, but when testing the script provided on the blog separately nothing happened. Would this be because the script was written in PowerCLI 4.0? I am currently running 4.1.1.
does anybody know how the capacity section is calculated? i have run the report and it told me i have 168 (est num vm left cpu) and 87 (est num vm left mem). what exactly is this telling me. i could setup 87 1gb memory vm’s?
Also Dead LUNS when I sent the report to the admin he would simply say ” I dont have any dead luns everything checks out fine…”
I tried the file attachment changes mentioned to send the report as an attachment. Upon completion I would receive an email but no attachment.
Any one else?
Pingback: vNiklas Virtualization blog » Second day of VMware vSphere PowerCLI Automation Course
I added limiting the scope to report only on a specific cluster, or hosts and/or VMs within a specific cluster. (I wanted to keep my various testing clusters out of the mix.)
Write-CustomOut “Collecting VM Objects”
If ($VMReportContainer -ne “”)
{ $VM = Get-VM -Location $VMReportContainer | Sort Name }
Else
{ $VM = Get-VM | Sort Name }
Write-CustomOut “Collecting Datacenter Objects”
$Datacenter = get-datacenter | sort name
Write-CustomOut “Collecting VM Host Objects”
If ($HostReportContainer -ne “”)
{ $VMH = Get-VMHost -Location $HostReportContainer | Sort Name }
Else
{ $VMH = Get-VMHost | Sort Name }
Write-CustomOut “Collecting Cluster Objects”
If ($ReportCluster -ne “”)
{ $Clusters = Get-Cluster -Name $ReportCluster | Sort Name }
Else
{ $Clusters = Get-Cluster | Sort Name }
Write-CustomOut “Collecting Datastore Objects”
$Datastores = Get-Datastore | Sort Name
Hope it helps someone with a similar need.
Based on the $ShowLunPath section, i wrote this to add a check for “Fixed” or “RoundRobin” multipath policy for each lun. If the path for a lun is not “RoundRobin” it will triggers a warning.
If you have decided to use this multipath policy it can be helpful.
Could be add in a future version on this script.
Need to add
# RoundRobin
$ShowRoundRobin = $true
at the start..and
# —- Round-Robin —-
If ($ShowRoundRobin){
Write-CustomOut “..Checking for Round-Robin on each LUN”
$Fixed = @()
foreach ($esxhost in ($VMH | where {$_.State -eq “Connected” -or $_.State -eq “Maintenance”}))
{
$esxluns = Get-ScsiLun -vmhost $esxhost -CanonicalName “naa.6006*”
foreach ($esxlun in $esxluns){
if ($esxlun.multipathpolicy -ne “RoundRobin”) {
$myObj = “” |
Select VMHost, Lunpath, MultipathPolicy
$myObj.VMHost = $esxhost
$myObj.Lunpath = $esxlun.CanonicalName
$myObj.Multipathpolicy = $esxlun.multipathpolicy
$Fixed += $myObj
}
}
}
If (($Fixed | Measure-Object).count -gt 0) {
$MyReport += Get-CustomHeader “FIXED LUN Path : $($Fixed.count)” “Some path are not using Round-Robin policy.”
$MyReport += Get-HTMLTable $Fixed
$MyReport += Get-CustomHeaderClose
}
}
@Mark T,
In the vCheck5 code around line 1574 you’ll see a line that says:
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV $MyReport
If you do not want the report to appear in the body you can modify/replace the $MyReport variable with your desired message body HTML. An example would be:
send-SMTPmail $EmailTo $EmailFrom “$VISRV vCheck Report” $SMTPSRV “vCheck is complete”
@Tracy M,
Great solution on limiting the vCheck scanning scope. I’m still confused how PowerCLI is using the other linked mode instances — I want my vCheck to do that 🙂
I found a way around my linked mode VCenter issue. And it should also work for those that only want to audit a certain segment (specific Datacenter, ESX Host) of their Environment. I created a local account on the Vcenter server that only has read-only access to the segments I want to be audited. For My environment since this local account only exists on the Primary Vcenter and not the linked ones, the audit cannot walk farther than the primary. Hope this helps someone else.
Thanks for a great script but I’m after a little bit of help. I’ve managed to amend it slightly as suggested above to send the report as an attachment but now I’m trying to remove it from the body of the email. Any suggestions will be gratefully received.
Thanks
Pingback: Audit VMware VM’s for Creator and write to vCenter VM notes with PowerShell and PowerCLI 4.1.1 | Learn Powershell | Achieve More
@Bwuch,
I ran the latest script 5.38 and it took about 2hrs and 20 mins to run. That is a huge difference! I am used to over 6.
@Pete L, just curious, do you have a lot of snapshots? If I’m reading the vCheck code correctly it may loop through nearly 1000 VI events for each snapshot (looking for the creation time and user name). If you have a lot of snapshots I could see that performing poorly.
I do have a modified version of vCheck…which includes the new snapshot check code from the other day. If you would like to test it you can get a copy here: http://bit.ly/kKvxw1
Oh, and yes, I do have a life and real job 🙂
@Bwuch
Hi first off thanks. I re-ran the vcheck 5.3 and about 6 hours later it emailed me a report. It just seems to take forever on the snapshot thing. Anyhow I finally had to kill that other job that was going for over 24hours and simply restarted it.
Anyhow you mentioned you wanted to make changes? Anyhow I appreciate your time and attention to this as I can appreciate you have a life and a real job as well? 🙂
@Kenny, it would be possible to add a section with all powered off VMs and the last time there was a power on event (I don’t see a way to determine the last time it was actually running). The code is already available here: http://blogs.vmware.com/vipowershell/2009/10/when-was-the-last-time-that-vm-was-powered-on.html — it just needs modified slightly so it fits into the vCheck framework.
@Tracy M, I’ve ran vCheck against a vCenter Linked Mode configuration before and it only returned the one specific vCenter results (I was actually wanting to get all of them). If you run the PowerCLI cmdlet Get-PowerCLIConfiguration what is listed under the “Default Server Mode” heading? Two modes are available (single|multiple) — I’m just curious if that could allow you to report on more than one vCenter.
@molski, the vCheck code can run against stand-alone ESXi hosts. However, some of the checks are not going to work (like the ones that look at the vCenter services and event logs). You could leave the checks running — since they return zero results they will not appear in the report. If you want to improve performance you may want to disable some of the inapplicable checks in the header section by chaning their status variable to $false. Here are a few of the ones I’d look for:
# VC Service Details
$ShowVCDetails = $true
# VC Event Log Errors
$ShowVCError = $true
# VC Event Log Warnings
$ShowVCWarn = $true
@Pete L, if you try to change the references from ‘host’ to ‘vmhost’ or ‘state’ to ‘connectionstate’ in the code you’ll find that it is used in various places and requires multiple updates (I know because I’ve done it). Once you fix the first one the next time you run the script it will warn you in a different spot (the warnings appear to display only once per console window session). I’ve got a couple more changes I would like to incorporate and then I’ll share the version I have with this already addressed.
Did you ever get past the snapshot check from yesterday? I’ve had blips in my network connection cause the script to appear to hang — and it usually doesn’t recover. I have an environment with about 900 VMs and 45 or so hosts and it only takes 2.5 hours to run the check. If the script is still hung from 5/13 7:23am I’d press CTRL+C to cancel and then try again. I’m not sure how large your environment is, but I’d hope the script doesn’t take 12 hours.
Pingback: EnterpriseAdmins.org » Blog Archive » vSphere Snapshot Report
UPDATE
I took vcheck 5.3 and started running it yesterday (May 12) @ 4:44PM Eastern. Today is the day after and it is still running (I think) :
4:44:08 PM Connecting to VI Server
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.
4:44:12 PM Collecting VM Objects
4:44:16 PM Collecting Datacenter Objects
4:44:16 PM Collecting VM Host Objects
4:44:25 PM Collecting Cluster Objects
4:44:25 PM Collecting Datastore Objects
4:44:25 PM Collecting Detailed VM Objects
4:45:00 PM Collecting Template Objects
4:45:01 PM Collecting Detailed VI Objects
4:45:01 PM Collecting Detailed Alarm Objects
4:45:02 PM Collecting Detailed VMHost Objects
4:46:20 PM ..Adding General Summary Info to the report
4:46:33 PM ..Checking Capacity Info
4:48:27 PM ..Checking Capacity Info (disk)
4:48:59 PM ..Checking Cluster CPU ratio
4:49:48 PM ..Checking Snapshots
It has been sitting at Checking Snapshots since 4:49PM yesterday May12. I am posting this the next morning at 7:23AM.
@bwuch (Brian),
First off I want to say “thank you”. I ran the vcheck script in the the u1 version of PowerCli and about 6 hours later I got a report on our virtual environment.
The only messages I saw in powercli were:
12:58:56 PM ..Checking Hosts in Maintenance Mode
WARNING: ‘State’ property is obsolete. Use ‘ConnectionState’ instead.
12:58:56 PM ..Checking Hosts Not responding or Disconnected
12:58:56 PM ..Checking Hosts Overcommit state
12:59:32 PM ..Checking Hosts Dead Lun Path
WARNING: ‘LunPath’ property is obsolete. Use ‘Name’ instead (it holds the same
value).
1:09:29 PM ..Checking for created or cloned VMs
1:10:09 PM ..Checking for removed VMs
1:10:10 PM ..Checking for VMs with over 2 vCPUs
1:10:10 PM ..Checking for VMs swapping or Ballooning
WARNING: ‘Host’ property is obsolete. Use ‘VMHost’ instead.
I will assume i just change those values and I am good to go?
Hi,
Great script, but I also would like to use it on some ‘stand-alone ESXi islands’ (without VC).
Any chance it can also work on a single ESXi host?
Regards,
Molski
@bwuch:
I upgraded powercli per your suggestion. Re-ran your code and within 7 minutes it provided me the results. No error messages!!!
Thanks! Now does this code still need to be incorporated into the vcheck?
p.s. as for the aging snapshots,… Yeah tell me about it.. Thus why I want to run this script and have it email the admins! 🙂 One admin has snapshots of over 200 days old in his 3.x environment. Now you can see why I want this script to function
@Pete L — Holy cow! I get bent out of shape if someone asks to keep a snapshot more than 3 days…I’m not even sure what to say about a 60 day old/59GB snapshot!
I do have some good news. I was able to re-create the warning message you see from an old PC I had with PowerCLI 4.0 U1 build 208462. Using the same user account/permissions on a different computer with PowerCLI 4.1 U1 build 332441 worked fine. Would it be possible to upgrade the PowerCLI version to 4.1U1 on your machine?
@bwuch
Ok here is an update from my comments above:
ran your script again. And within 3 minutes I received the message :
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
so I decided to do other things on the pc and see if results would magically appear again delayed sorta speak cause I do have the error message above but no prompt.
Then about 15 minutes the results displayed:
here is a small sample:
VM : MACHINEAP03 – PDF Converter
SnapshotName : Consolidate Helper- 0
DaysOld : 60
Creator :
SizeMB : 59348.03
Created : 3/12/2011 10:11:58 AM
Description : Helper snapshot for online consolidate.
Wait a minute!
After I got that error I walked away from the PC when I came back it displayed virtual machine names with snapshot information..!!
Hmm I am going to run again
Bwuch,
thanks for doing this.. However ran the script and got the following result after a few minutes:
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
@Pete L,
The code vCheck uses to collect snapshot data is fairly complex…I’ve tried to re-write and simplify that section. The following script contains only the new snapshot collector code: http://enterpriseadmins.org/blog/wp-content/uploads/2011/05/troubleshootSnapshots.ps1_.txt
Could you try and run this (independently of vCheck) and see if this code works without warning? If so I can help you retrofit the new code into vCheck 5.
Thanks!
We have a primary Virtualcenter that is connected to 3 other virtualcenters in linked mode. When I run the script against the primary virtual center (and wanting it to just return the contacts of the primary) the script is crawling all of the linked VC’s as well and taking over an hour to finish. Is there a way to have it not crawl the linked VC’s or specify just the Datacenter you want it to inventory?
@bwuch
running get-vm |get-snapshot worked fine and provided me with output to the screen of the machines with snapshots.
.
So I am now puzzled.. 🙂 How can I get this to work when it runs it report in the script?
I will be a happy man.. 🙂
@Pete L,
Here is another idea…the vCheck script is doing some fairly complex stuff with regard to snapshot size. Looking through the code I do not see any custom error messages related to permissions in the snapshot sections — which makes me believe that the error is produced by a native PowerCLI function. To simplify troubleshooting, can you try running the following command:
get-vm |get-snapshot
I also noticed that a newer version of PowerCLI was available (VMWare vSphere PowerCLI 4.1 U1 build 332441). The release notes do not mention fixes in Get-Snapshot, but it might be worth trying.
I am not sure what else to try.. H’mmmm :
10:53:17 AM Connecting to VI Server
10:53:17 AM Collecting VM Objects
10:53:24 AM Collecting VM Host Objects
10:53:36 AM Collecting Cluster Objects
10:53:37 AM Collecting Datastore Objects
10:53:37 AM Collecting Detailed VM Objects
10:54:12 AM Collecting Template Objects
10:54:14 AM Collecting Detailed VI Objects
10:54:15 AM Collecting Detailed Alarm Objects
10:54:15 AM Collecting Detailed VMHost Objects
10:55:39 AM ..Adding General Summary Info to the report
10:55:59 AM ..Checking Capacity Info
10:58:25 AM ..Checking Snapshots
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
Hi. I already checked all of that but here is the result to post to the masses after running the version cmdlet: (as you can see I meet the version requirements)
[vSphere PowerCLI] C:\> get-powercliversion
PowerCLI Version
—————-
VMware vSphere PowerCLI 4.1 build 264274
[vSphere PowerCLI] C:\>
As for rights. I have all the required rights (admin)
@Pete L,
I’ve just tested the script and do not get the ‘insufficient permissions’ error message with a read-only vCenter user. I did find reports of this problem on the VMware Communities forum at http://communities.vmware.com/thread/251568?start=15&tstart=0. One of the suggestions in that thread is to verify the version of PowerCLI:
Please verify that the latest build [of PowerCLI] is installed correctly: run Get-PowerCLIVersion cmdlet and verify the output is “VMware vSphere PowerCLI 4.1 build 264274”
Brilliant script! Took about 6 hours to run, but the end result was spot on. Is there a way to incorporate within the report a section stating all powered off VMs and their Last Powered On date and time with the results in descending order, “oldest to most recent”?
Any help with regards to this would be greatly appreciated.
Hello – anyone have a solution for this. I am not certain what else to try..
WARNING: Unable to populate snapshot size due to unsiffucient permissions
thanks for reading. 🙂
Hello Simon.
I simply used the instructions provided and wondered why it did not work. So i just did what I did but thanks for the tip. However that is no longer concern of mine anymore as I am able to get by via the hard coding I did. I am running this script as a domain admin and I have full admin rights in vcenter.
The next issue I wish to resolve is that pesky error with the snapshots. Insuffecient permissions”
Pete L
At the beginning of the script it starts “param( [string] $VISRV)”. So you pass the name of your management server to the script as a paramenter. That saves you having to change the script each time you run it against a different management server!!!
What permissions role are you running the script as ? The easy solution is obviously to run it as an admin…
Well – great script and I am sure many hours are poured into this and provided to the community. To that I say bravo. However I do not see many folks having any of their issues resolved. (perhaps I am mistaken)
Anyhow I got past my issue with the the “Connect-VISERVER Cmdlet did not work, please check you VI Server”. Albeit perhaps not the best way but what I did is remove the variable $VISRV by simply hardcoding my virtual center server name in those 7 locations within the script. If I need to connect to another vcenter then I would change that name. I know not the best but I am no powershell expert when i was trying to debug it I kept getting messages saying that value is empty even though I typed my server name for it to connect.
Now on to the following error:
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
I see other folks asking but no solutions?? Has anyone got passed this????
The check for ESXi Lockdown Mode doesn’t work correctly. I changed the line:
$ESXiUnlocked = @($ESXiLockDown | Where { $_.LockedMode -eq “False” })
into:
$ESXiUnlocked = @($ESXiLockDown | Where { -not $_.LockedMode })
to make it work. The problem is that $_.LockedMode is a boolean and not a string.
Bah. Answered my own question. Running it from the vcenter server didn’t work. Running it from my local desktop worked fine. Weird, no?
Hmm, my report is only showing 1 host, 1 vm, 1 datastore, etc. when I have bunches of each). The script authenticates fine (as I can use the connect-viserver command fine alone). I’m pretty new at PowerCLI (let alone PowerShell). Any hints as to what to look for? Is there a debug mode?
Pingback: PowerShell Scripts And The ExecutionPolicy Issue | DeinosCloud
Pingback: vCheckv5 Script And The ExecutionPolicy Issue | DeinosCloud
When I see stuff like this, I realize how much of a no0b I am 😛
Awesome Script, got it running a part of our operations team daily checks.
thanks.
I am new to PowerCLI and I love it. This report is very helpful. I am having a small issue when I run it. When the report is completed, it is showing duplicates of everything. (Number of host showing 14 and we only have 7, VMs showing 128 and we only have 64, Snapshots are showing twice) Any ideas why that would be showing up this way?
Hi,
the script run fine but it take only 5 minutes to finish…
but there’s no dispay in IE, no file in C:\tmp
could someone tell me why ?
Not getting any emails, even after chainging the code to send as attatchment as per above comments.
This is run on the vcenter server 4.1.0 box
Still runs fine on my old virtual center 2.5 box (with the script execution pointed at the new vc)
Great Script! any idea how to schedule the script to run daily/weekly?
Cheers.
Has anyone else had any problems getting it to report VM Disk space available?
# VM Disk space left, set the amount you would like to report on
$MBFree = 10000
Changed Block Tracking (CBT) is the ability of a virtual machine to keep track of disk sectors that have changed. The CBT feature can be accessed by third-party applications as part of the vStorage APIs for Data Protection. Applications can use the API to query the VMkernel to return the blocks of data that have changed on a virtual disk since the last backup operation. Detail is available here: http://kb.vmware.com/kb/1020128.
If you have a backup solution that leverages CBT, you’ll want to make sure these bits are enabled. The code is very good in that it not only checks for CBT, but allows you to configure if the default CBT value should be enabled or disabled. For example, if your backup solution does not use the vStorage APIs for Data Protection you probably do not want the overhead of tracking which blocks change.
By the way, I found vcheck from the book I received this week:
VMware vSphere
PowerCLI Reference
c2011
Pages 430, 656-657
I’m using a read-only account for safety, one of the VCs I access also gives me the typo’d error message:
5:00:00 PM ..Checking Snapshots
WARNING: Unable to populate snapshot size due to unsiffucient permissions.
‘unsiffucient’?
Doesn’t appear to come from the script.
Why would you care about CBT anyway ? I would like to know the benefit of the added code.
Hi
Ok, I have updated my CBT code to actually work, its not the most elegant but does work
# Show CBT Variations
$ShowCBT = $true
$CBTdefault = “true”
# —- Show CBT —– #
if ($ShowCBT) {
Write-CustomOut “..Checking for CBT status”
$cbt = @()
foreach ($vmguest in ($VM | get-view))
{
$name = $vmguest.name
$vmguest.Config.ChangeTrackingEnabled | %{
if ($CBTdefault -eq ‘true’){
if (!$vmguest.Config.ChangeTrackingEnabled -eq ‘true’){
$myObj = “” |
select Name,ChangeBlockTrackingStatus
$myObj.Name = $name
$myObj.ChangeBlockTrackingStatus = $vmguest.Config.ChangeTrackingEnabled
$cbt += $myObj
}
}
else {
if ($vmguest.Config.ChangeTrackingEnabled -eq ‘true’){
$myObj = “” |
select Name,ChangeBlockTrackingStatus
$myObj.Name = $name
$myObj.ChangeBlockTrackingStatus = $vmguest.Config.ChangeTrackingEnabled
$cbt += $myObj
}
}
}
}
If (($cbt | Measure-Object).count -gt 0 -or $ShowAllHeaders) {
if ($CBTdefault -eq ‘true’){
$myReport += Get-CustomHeader “Change Block Tracking Disabled Count : $($cbt.count)”
}
else{
$myReport += Get-CustomHeader “Change Block Tracking Enabled Count : $($cbt.count)”
}
$myReport += Get-HTMLTable $cbt
$MyReport += Get-CustomHeaderClose
}
}
Thanks
@Travveler: You can attach the report but not display it – Use the modifications from @shartma and enable $DisplayToScreen — just comment out the Invoke-item so the report is never actually displayed during runtime:
if ($DisplayToScreen) {
Write-CustomOut “..Displaying HTML results”
if (-not (test-path c:\tmp\)){
MD c:\tmp | Out-Null
}
$Filename = “C:\tmp\” + $VIServer + “vCheck” + “_” + $Date.Day + “-” + $Date.Month + “-” + $Date.Year + “.htm”
$MyReport | out-file -encoding ASCII -filepath $Filename
#Invoke-Item $Filename
Hi Alan,
Great updates. Can you add some checks for SRM protected VM’s.
Hi
Here is some code to find which machines have change block tracking disabled. there is a problem with the logic. Ill sit down at some point and look again. But current code is below, let me know if it can be improved upon
# Check for Disabled Change Block tracking (not complete, some logic is wrong, and will only report on FALSE at present (ESX4 or above required))
$ShowCBT = $true
$CBTdefault = “True”
# —- Show CBT —– #
if ($ShowCBT) {
Write-CustomOut “..Checking for CBT status”
$cbt = @()
foreach ($vmguest in ($VM | get-view))
{
$name = $vmguest.name
$vmguest.Config.ChangeTrackingEnabled | %{
if (!$vmguest.Config.ChangeTrackingEnabled -eq $CBTdefault){
$myObj = “” |
select Name,ChangeBlockTrackingStatus
$myObj.Name = $name
$myObj.ChangeBlockTrackingStatus = $vmguest.Config.ChangeTrackingEnabled
$cbt += $myObj
}
}
}
If (($cbt | Measure-Object).count -gt 0 -or $ShowAllHeaders) {
if ($CBTdefault -eq ‘true’){
$myReport += Get-CustomHeader “Change Block Tracking Disabled Count : $($cbt.count)”
}
else {
$myReport += Get-CustomHeader “Change Block Tracking Enabled Count : $($cbt.count)”
}
$myReport += Get-HTMLTable $cbt
$MyReport += Get-CustomHeaderClose
}
}
Hope this proves usefull to someone
Thanks
Hi – great script!
Q: v5 reports ballooning for a few VMs – but I go into VI client performance->memory and the ballooning shown there (this is ESXi 4.1U1) is Zero for realtime, day, week.
Can you explain the script reporting ballooning, but VI client reports zero ballooning of memory?
thanks!
How long does it run for? I ran the script and it is stuck at checking “capacity info” for more than 16 hours. It would be nice if there is some kind of logging to find whats going on… Is it normal to be collecting capacity info for 16 hours? I have around 20 ESX and a handful of datastores.
@Mark, I believe the warnings you see relate to changes in PowerCLI 4.1U1. The script will still run with the warning in place and the results of the check are still accurate. However, if you don’t want to see these warnings, you can check out the modifications I’ve made to Al’s awesome vCheck script. The latest changes I’ve made are available here:
http://enterpriseadmins.org/blog/scripting/vcheck-daily-report-version-5-31/
I’ve added a handful of feature requests — found from right here in the comments — plus a few other things I wanted along the way.
I hope this works for you!
I’ve just implemented the script on a W2K8 R2 server with vSphere 4.1. When I manually kick off the script I see a couple errors in the PowerShell window.
First error is after Host & Maintenance Mode:
Warning ‘State’ property is obsolete, use ‘ConnectionState’ instead.
Second error is after VMs Swapping & Ballooning:
Warning ‘Host’ property is obsolete, use ‘VMHost’ instead.
Tried swappping the recommendation out in a couple of places for the first warning and saving the script, then running but still got the warning… Any ideas?
Thanks
What is the format for the credentials file. What to automate the running of this script.
Oh yeah, im also working on the performance in the next version, trying to make it faster !
Yes you can, it was designed to be run as a scheduled task, check here for more info on how to do this: http://www.virtu-al.net/2009/07/10/running-a-powercli-scheduled-task/
I have 2 VC’s and this script takes for every to run. I have 58 Hosts and 783 Guests in one VC and 43 Hosts and 388 Guests in the other VC. Can I automate this script to run overnight? How?
also having the “multiple prompts for credentials” issue when running this script on a windows 2008 R2 (where vCenter is installed) desktop session with AD account nested in local admin group.
no difference if i run it from power VMware CLI window, called out from a command prompt, or from scheduled task.
Pingback: EnterpriseAdmins.org » Blog Archive » vCheck (daily report) version 5.31
Pingback: VMware vCenter ADAM_VMwareVCMSDS Warning : My Geek Finds
@Simon, I’m the one with the vCheck feature request spreadsheet. I’ve posted the list on Google Docs here: http://bit.ly/dGrNjh. You can check out my web site to find the changes I’ve added.
Where has that guy gone with the spreadsheet of all the proposed updates ? Or has Al included them himself already ?
These are the credentials to access your vCenter to read the event logs – Windows credentials
I keep getting a log in request at these points:
..Checking VC Services
..Checking VC Error Event Logs
..Checking VC Warning Event Logs
I don’t know which password it wants. Does anyone know how to get this to go away? The information I get from the script is very useful, but I can’t schedule it to go on its own when it stops for these pop-ups.
Thanks
Hi, First of all, thanks for this script, it’s amazing ! I have no scripting knolwedge and I’ve even managed to implement it successfully. Could I add something for a wish list, or if someone has already added this could you let me know the code… I would also like to have a section which reports on disk alignment. I have seen a number of individual scripts, but I’d like to be able to incorporate, it into this excellent script…many thanks for any help you can give me….
Excellent script 😉 I have the same problem getting the output as an attachment as Samir described…..
I have Changed function Send-SMTP to below:
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body, $Filename) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$att = new-object Net.Mail.Attachment($Filename)
$msg.Attachments.Add($att)
$msg.IsBodyHTML = $true
$mailer.send($msg)
}
Added $Filename to the function Send-SMTPmail line and added:
$att = new-object Net.Mail.Attachment($Filename)
$msg.Attachments.Add($att)
But still the report is not coming as attachment.
What else do I need to do?
How to know? Many times. I think it never uses the credentials stored in the encrypted file. It asks int the begining, and three or four times during the execution of the script. If I insert the same credentials (the one used in the bigining) works fine.
Credentials for vCenter or for the WMI calls it makes to the VMs ?
I’m having problems with the credentials. Can’t schedule this script because it asks for username and password many times. Any solution???
Hi there,
it´s a great script. But i have a “Feature” Request.
It is possible to change the snapshot check so that i get only the size of the snapshot files? Not the whole used space?
I found a script that do this, but i am not familiar with PowerCli to implement it.
Bye Christian
Thanks… It worked… 🙂
@Samir – I haven’t tested this, but I believe you could change this line:
$Filename = “C:\tmp\” + $VIServer + “vCheck” + “_” + $Date.Day + “-” + $Date.Month + “-” + $Date.Year + “.htm”
-to-
$Filename = “C:\tmp\” + $VIServer + “vCheck” + “_” + $Date.Day + “-” + $Date.Month + “-” + $Date.Year + “_” + $Date.Hour + “-” + $Date.Minute + “.htm”
To add the hour and minute to the output file. You’ll note I used a dash between hour & minute — if I remember correctly, a colon is not a valid character to use in a file name.
Just a quick question. I am running the script twice a day. but due to the same name of the report generated e.g. VCproductionvCheck_14-1-2011.htm. The previous report gets over written. is it possible to have the output reports name contain timing e.g vmcpesuwp01lcvCheck_14-1-2011_12:08.htm
Since other people are submitting requests, I’ll add mine. Most of them are storage centric but I think everyone would benefit from it.
– Top 10 VM consumers of host disk IP (over x number of days).
– Top 10 datastores with highest latency (over x number of days).
– Top 10 datastores with lowest latency and most free space (helps decide where to put the next VM).
– VMs with disk latency higher than x (over x number of days).
The more focus we can put on storage the better performance gets! If you need 48 hours, let me know and I’ll do what I can.
With all these good enhancements going on its probably worth mentioning two issues I’ve seen;
1) With the “The following VMs are located on storage which is only accesible by 1 host,” check, local disks are listed. Should these not be excluded ?
2) The capcity data seems misleading. One cluster shows on the report under CPU that it can have 1500 additional machines based on HA requirements, and yet I know that cluster is reaching significant CPU contention caused mainly by the number of VM’s with 4 vCPU’s.
Also all clusters are reporting as having capacity for hundreds of additional VM’s based on memory, and then all the hosts are listed as having over commited memory. I realise one is based on allocated and the other on used, but the data will surely give people an unrealistic picture of their actual capacity situation ?
I’m being picky of course – its a great report and VMWare would do well to include all this info in the VI client….!
Hello Guys,
I have Changed function Send-SMTP to below:
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body, $Filename) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$att = new-object Net.Mail.Attachment($Filename)
$msg.Attachments.Add($att)
$msg.IsBodyHTML = $true
$mailer.send($msg)
}
Added $Filename to the function Send-SMTPmail line and added:
$att = new-object Net.Mail.Attachment($Filename)
$msg.Attachments.Add($att)
But still the reports is not coming as attachment.
Any idea ?
Al, I’ve posted the spreadsheet and modified version of the script on my blog – http://enterpriseadmins.org/blog/?p=238 for your review. I’ve only tested it on one vCenter so other environments may uncover additional issues/problems. Thanks again for creating this script!
I noticed that the VM disk space check would only report on
the 1st disk in the VM. I also would like to report on % free in
addition to MB free. For example, report on all VM disks that have
less than 5% free AND 500MB free. I added the following code to
accomplish the task…. Add this to the details settings section of
the user configurable variables: # VM Disk space left, under x
percent free and under x MB free $diskPercFree = 5 $diskMBFree =
500 Add this to the 2nd user configurable area: # Show VMs disk
space check $ShowGuestDiskFree = $true Add this to the body of the
script. (I added it below the existing section “—- VM Disk Space
– Less than x MB —-” # —- VM Disk Space – Less than x percent
—- If ($ShowGuestDiskFree){ Write-CustomOut “..Checking for
Guests with less than $diskPercFree percent” $MyCollection = @()
$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where {
$_.Runtime.PowerState -eq “poweredOn” -And ($_.Guest.toolsStatus
-ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne
“toolsNotRunning”)} $SortedVMs = $AllVMs | Select *,
@{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object
-Descending NumDisks ForEach ($VMdsk in $SortedVMs){ $myCol = @()
Foreach ($disk in $VMdsk.Guest.Disk){ $CapacityMB =
([math]::Round($disk.Capacity / 1MB)) $FreeSpaceMB =
([math]::Round($disk.FreeSpace / 1MB)) $_ = “” | Select-Object
Name, Path, CapacityMB, FreeSpaceMB, PercFreeSpace $_.Name =
$VMdsk.Name $_.Path = $disk.DiskPath $_.CapacityMB = $CapacityMB
$_.FreeSpaceMB = $FreeSpaceMB $_.PercFreeSpace =
([math]::Round(((100 * ($FreeSpaceMB)) / ($CapacityMB)),0)) $myCol
+= $_ } $MyCollection += $myCol } $VMPercFreeWarn = @($MyCollection
| Where {$_.PercFreeSpace -lt $diskPercFree -and $_.FreeSpaceMB -lt
$diskMBFree} | Sort Name) If (($VMPercFreeWarn |
Measure-Object).count -gt 0) { $MyReport += Get-CustomHeader “VMs
with less than $diskPercFree % free AND $diskMBFree MB free :
$($VMPercFreeWarn.count)” “The following guests have less than
$diskPercFree % Free AND $diskMBFree MB Free, if a guest disk fills
up it may cause issues with the guest Operating System” $MyReport
+= Get-HTMLTable $VMPercFreeWarn $MyReport += Get-CustomHeaderClose
} }
Al,
Have you ever thought about open sourcing it, etc? There are licenses that would allow you to keep things from forking, but would allow a larger portion of the community to participate and continue to improve on this already great script.
At a minimum move to a community based approach with hosting on a source forge, github, code plex type repository.
I think you would see some great additions from the community.
hi, v3 worked perfect in my environment but v5 hangs on
that point: 13:30:06 Connecting to VI Server 13:30:06 Collecting VM
Objects 13:30:08 Collecting VM Host Objects 13:30:10 Collecting
Cluster Objects 13:30:10 Collecting Datastore Objects 13:30:10
Collecting Detailed VM Objects 13:30:13 Collecting Template Objects
13:30:13 Collecting Detailed VI Objects 13:30:14 Collecting
Detailed Alarm Objects 13:30:14 Collecting Detailed VMHost Objects
13:30:19 ..Adding General Summary Info to the report 13:30:26
..Checking Capacity Info any ideas? thanks
That’s great, cant wait to try out your changes and add them to v6, please do send over the spreadsheet and I will add it to the list I have in mind. I love the way people can pick this up and adjust it, that’s one of the things I wanted to be easy when creating the script!
Great script. Helps me allot to get a overview over my
VMware Cluster!
Al – Just wanted to say that you’ve got a great script here. If it were possible I would be glad to give you a couple of hours of my day so you could work on this 🙂
I’ve spent a couple of hours recently trying to add some features and document other requests. I have a spreadsheet listing some of the requested features (from all the comments on this post) and an updated script with a dozen or so of those features added. I would be glad to share them with you if you are interested.
Thanks again!
Pingback: EnterpriseAdmins.org » Blog Archive » vCheck (Daily Report)
it appears that html is not supported, the link to the
image is ‘http://img840.imageshack.us/img840/1930/lockedz.jpg’
also, thanks for the tip for multiple NTP servers, worked great for
my environment.
I noticed for some time now that the script (at least in my
ESXi 4.1 and power CLI 4.1.1 environment) that the lockdown mode
portion shows false positives even though lockdown mode is enabled.
the result even shows all the hosts as LockedMode is “true”.
searched though the comments to see if anyone is experiencing this,
see image for example (i hope html is supported). Uploaded with ImageShack.us any ideas?
thanks.
I will do you a deal, give me 2hrs of your day and I will write it 🙂
Ha! Good timing – I just happened to be looking for another script when I decided to add my comment. I didn’t see Al’s message two above mine!
Any plans to write an updated script?
Well we all appreciate your efforts even if the wife doesn’t!
If you do add that script it would be worth adding an exclusion for local disks…(in my opinion)
Just as an FYI – I get this warning “WARNING: ‘State’ property is obsolete. Use ‘ConnectionState’ instead.”
I agree, that would be a great addition, maybe one day I will get time to update this script with this and the other ideas I have! Perhaps I should make a chargeable version of the script – at least that way it would make it justifiable to the wife when I work weekends ;). Great idea though!
Good script. The only thing this is missing is a comparison
of all the hosts in each cluster – along the lines of this
http://www.peetersonline.nl/index.php/vmware/check-vmware-configuration-with-powershell/
I know this should only need to be done when new LUN’s or VLAN’s
are added, but in reality we have had occasions where for one
reason or another it was an issue. Of course those using profiles
don’t have to worry 🙂
My previous solution was an advantage but is not perfect. I still see messages with a future date in januari 2011. So I changed the line starting with if into:
if ($Details.Time.Month -gt $Today.Month -or ($Details.Time.Month -eq $Today.Month -and $Details.Time.Day -gt $Today.Day)) {$Details.Time = $Details.Time.AddYears(-1)}
The only problem still left is that it is possible that you will see error messages from a previous year. I think it is not possible to solve this problem untill the Get-Log cmdlet returns a date with the year included.
Since the first of januari the vCheck report shows events in the future in the “ESX/ESXi VMKernel Warnings” section. Of course I like a script that reports about future events ;-). But I think in this case it is a bug. The PowerCLI Get-Log cmdlet returns messages with a date without the year. E.g. “Dec 12 06:07:32”.
The line in the code:
“{$Details.Time = ([datetime]::ParseExact(($_.split()[0] + ” ” + $_.split()[1] + ” ” + $_.split()[2]), “MMM dd HH:mm:ss”, $SysGlobalization))}”
converts this date into “12-12-2011 6:07:32”. Which has the wrong year.
You can solve this problem by adding the following lines of code at the appropriate places to the vCheck script:
$Today = Get-Date
if ($Details.Time.Month -gt $Today.Month) {$Details.Time=$Details.Time.AddYears(-1)}
You should be able to separate your ntp server entries with a pipe symbol for this to work.
Excellent Script!!!
I have multiple NTP servers set on some ESXi servers and the report says the NTP settings are not correct. I have added both of the IP addresses for the NTP servers in, $ntpserver = “10.1.10.130,10.1.10.131”, but it still says the settings are not correct. I have tried with no comma between IPs and with just a space between IPs. Ideas?
Our email server requires authentication to send an email out, is there a way to put a user name and password for the SMTP server in?
Thank you for producing such a great checking/reporting
script and making it freely available! When I execute the script
(using VMware-PowerCLI-4.1.1-332441), I receive the following
warnings, but the problem I have is the script seems to
hault/freeze on the “.. Checking Snapshots” section. I was only
able to successfully run the script to completion after commenting
out the ‘Snapshot’ section: > .\vCheck5.ps1 {VI_SERVER}
Connecting to VI Server WARNING: Index was outside the bounds of
the array. ..Checking for Map disk region event ..Checking Hosts in
Maintenance Mode WARNING: ‘State’ property is obsolete. Use
‘ConnectionState’ instead. ..Checking Hosts Not responding or
Disconnected ..Checking for VMs swapping or Ballooning WARNING:
‘Host’ property is obsolete. Use ‘VMHost’ instead. I’d very much
like to have the Snapshot information included, are you aware of an
issue with the Snapshot function working in this version of
PowerCLI? I’d very much like to include this information, is there
a fix or work-around that can be applied? Thank you in
advance.
Great script!
I hope you don’t mind but I added a few lines of code to attach the rendered HTML file as an attachment to the e-mail. Outlook 2007 doesn’t support some of the CSS that’s specified in the script.
Changed function Send-SMTP to below:
function Send-SMTPmail($to, $from, $subject, $smtpserver, $body, $Filename) {
$mailer = new-object Net.Mail.SMTPclient($smtpserver)
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)
$att = new-object Net.Mail.Attachment($Filename)
$msg.Attachments.Add($att)
$msg.IsBodyHTML = $true
$mailer.send($msg)
}
Added $Filename to the function Send-SMTPmail line and added:
$att = new-object Net.Mail.Attachment($Filename)
$msg.Attachments.Add($att)
in the middle.
Then I added “$Filename” to line 1574.
There’s most likely a better way to do this, but works for me.
Does anyone know how to add a section that will notify you of orphaned VMDKs?
@ Robert
No problem 🙂 I got the script running, many thanks.
I have another question… I am running this script against two separate VC’s. I have 2 separate scheduled tasks configured, pointing at the same script in the same location. When the script runs inititally it creates the mycred.crd file. I assume this will cause an issue if I run the script against 2 VC’s as it can’t create mycred.crd twice in the same location? I also presumed that, if using the same user account to run against the second VC (I have the same account configured with the same permissions on both VC’s), that it would work, unless the encryption algorithm generates some other value, possibly based on the server it is connecting to.
So I created 2 separate copies of vCheck in separate locations. I then ran the script. It seemed to work normally to start with, asking for the authentication initially which I entered. However, after warning about the SSL certs, it then prompted for authentication again. I entered the creds and the script carried on executing normally with no further interaction. After the script had finished, I ran it again, but once more was prompted for creds twice before it would execute.
So I am wondering where the issue lies? I have modified the script so the absolute path to the mycred.crd file is given in both cases, but this makes no difference. Does PoSh cache the mycred.crd value somewhere? I am able to run the script if I pass the VC UID and password in the script, so I am happy the account has the correct permissions. Has anyone seen this before?
@Rich B
The hyphen in front of the vCenter Server name was a typo. So you should remove the hyphen ;-).
@Robert
Sorry Robert, one last query. Where you pass the vc host name you have prefixed with ” – “. Is that required? My VC has a hyphen as part of the host name – will that cause an issue?
@Robert
oops… sorry our replies crossed over there!
Thank you
regards
@Robert
Thank you again.
Firstly, do I need to pass the -psconsolefile option as I have specified it in the script? Secondly, where in the string you detailed does it pass the vCenter host name?
regards
I see that in my previous post the command line was missing a piece. Probably by inapropriate handling of accolades by the web site software. I will try again. Replace ampersand, accolade-open and accolade-close with the appropriate signs:
%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -command “ampersand accolade-open c:\vCheck.ps1 -vCenterServerName accolade-close” > vCheck–vCenterServerName.log 2> vCheck-vCenterServerName-error.log
@Rich B
I wil show you how I run the vCheck script. First, I run the scheduled task with a service account that has sufficient right at the vCenter server. Second, the scheduled task runs a .cmd file with the following line of code:
%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1” -command “” > vCheck-vCenterServerName.log 2> vCheck-vCenterServerName-error.log
Replace vCenterServerName with the name of your vCenter server.
All the normal messages of the script will go to the vCheck-vCenterServerName.log file. The error messages will go to the vCheck-vCenterServerName-error.log file.
For everybody complaining about the speed of the vCheck script try installing the latest PowerCLI version 4.1U1. It made running the vCheck script in my environment much faster.
@Robert
Robert I ran the command and set proxy as disable all. I ran the scheduled task but it failed again with the same error. It works ok when run from the shell, so still think the issue is with the task scheduler – just not certain whether the issue is that it hasn’t passed the VI server info or the credentials.
Is there any way of forcing std error output to a log file from the posh script?
regards
I was also wondering… is there a way to force task scheduler to show the posh window as the task executes?
Thanks Robert.
Does PowerCLI try to use the proxy (if configured) even if the exclusion list includes addresses on the same network?
testing now…
I made an extension to the vCheck script to check for ESX servers that are not compliant with the VMware Update Manager attached baselines. Don’t forget to install the VMware vCenter Update Manager PowerCLI before you try my code. Enjoy!
# Hosts not compliant to VMware Update Manager Baselines
$ShowHostVUMNonCompliance = $true
# —- Hosts VMware Update Manager Baseline non-compliance —-
If ($ShowHostVUMNonCompliance){
Write-CustomOut “..Checking Hosts VMware Update Manager Baseline non-compliance”
Add-PSSnapin -Name VMware.VumAutomation
$NonCompliance = Get-VMHost | Sort-Object -Property Name | Get-Compliance | Where-Object {$_.Status -ne “Compliant”}
If (($NonCompliance | Measure-Object).count -gt 0) {
$MyReport += Get-CustomHeader “Hosts VMware Update Manager Baseline non-compliance : $($NonCompliance.count)” “The following hosts are not compliant to the attached baselines”
$MyReport += Get-HTMLTable ($NonCompliance | Select-Object -Property @{N=”Host”;E={$_.Entity}},@{N=”Baseline”;E={$_.Baseline.Name}},Status)
$MyReport += Get-CustomHeaderClose
}
}
The “The Connect-VISERVER Cmdlet did not work, please check you VI Server.” error message is probably due to your proxy settings.
Use the following cmd to set your powercli to bypass the proxy and try connecting again:
Set-PowerCLIConfiguration -Proxy “NoProxy”
has anyne got this running on Win 2k8 x64 as a scheduled task? I can get the task to run, but it fails after 5 minutes and forwards an email with the error:-
The Connect-VISERVER Cmdlet did not work, please check you VI Server.
I am passing the command directly into the scheduler as follows:-
Program/Script = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add Arguments (Optional) = -noexit “& ‘d:\ecoshell_scripts\vcheck\vcheck5.ps1′” my-vcenter
I am using a cred file to pass the authentication, so I am not sure if the error is caused because the VC info has not been passed, or the UID and password.
I have modified the following section of the script to try to make it use the cred file:-
If ($SetUsername -ne “”){
if ((Test-Path -Path $CredFile) -eq $false) {
Set-Cred $CredFile
}
$creds = Get-Cred $SetUsername $CredFile
}
Write-CustomOut “Connecting to VI Server”
$VIServer = Connect-VIServer $VISRV -Credential $creds
If ($VIServer.IsConnected -ne $true){
# Fix for scheduled tasks not running.
$USER = $env:username
$APPPATH = “C:\Documents and Settings\” + $USER + “\Application Data”
#SET THE APPDATA ENVIRONMENT WHEN NEEDED
if ($env:appdata -eq $null -or $env:appdata -eq 0)
{
$env:appdata = $APPPATH
}
$VIServer = Connect-VIServer $VISRV -Credential $creds
If ($VIServer.IsConnected -ne $true){
Write $VIServer
send-SMTPmail -to $EmailTo -from $EmailFrom -subject “ERROR: $VISRV vCheck” -smtpserver $SMTPSRV -body “The Connect-VISERVER Cmdlet did not work, please check you VI Server.”
exit
}
I’m not sure what impact the ‘# Fix for Scheduled Tasks Not Running’ has. It seems to be mapped for a Windows 2k3 environment rather than 2k8, but that is probably irrelevant. Maybe my syntax is wrong or incomplete. Anyone have any ideas, or been able to get this to work with task scheduler?
Samir, That’s normal, the reason for that is that the “default” install of your vcentre uses an certificate that does not match your hostname, the script should still work, did it produce an email ok ?
If you really want to get rid of the message you will need to install a certificate, see http://kb.vmware.com/kb/1021514 for details on how to.
Regards
Neil
Hello Neil,
Thanks for the reply.
Now i am getting the below message. Any idea why ?
“There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated i
der.
* A required certificate is not within its validity period.
* The certificate’s CN name does not match the passed value.
Hi Samir, try the following
edit your vcheck5.ps1 script, add the following line as line 2 in the script.
add-pssnapin VMware.VimAutomation.Core
save script and then try running .\vcheck5.ps1 vmcpaup01lc
if that still doesn’t work, check you have all the prereqs installed.
◦PowerShell V2 Download from http://support.microsoft.com/kb/968929
◦PowerCLU 4.0 U1 or later version Download from http://www.vmware.com/support/developer/PowerCLI/index.html
Regards
Neil
Hello Rich,
I have changed the script to
Write-Host “Please specify a VI Server name eg….”
Write-Host “powershell.exe vCheck.ps1 MyvCenter”
Then I ran this command on powershell.
.\vCheck5.ps1 vmcpaup01lc
I received an email saying that
The Connect-VISERVER Cmdlet did not work, please check you VI Server.
I think i am really bad in scripting 🙁
Sorry, my bad.
Syntax on the command is .\vcheck.ps1 myvcenter
I never could get my slash orientation correct 🙁
No problems Samir.
Firstly, you do not need to modify the script on the lines you mentioned. The ‘write-host’ command just outputs info to the shell, such as error messages. If you have received the message it is because the script does not know which vCenter to connect to.
Secondly, from the PowerCLI shell, CD to the directory where your script is located and use the command:-
./vcheck.ps1 myvcenter
Where myvcenter is the host name of your vCenter server, and assuming the script is called vcheck.ps1. This will launch the script and you should see response output in the shell as it executes.
Hope that makes sense 🙂
Hi Rich,
Please spare me for not understand the script and how will i get the output.
i m using Windows Power Shell 1.0. I have entered the vCenter Server as below. Do i need to enter the VC server name somewhere else.
Write-Host “Please specify a VI Server name eg….”
Write-Host “powershell.exe vCheck.ps1 vmcpaup01lc”
Note: I am running this script on VC server itself.
@ Samir
Are you running it from the PowerCLI shell Samir? Did you specify a vCenter Server in the string?
when i run the script it gives only the below message.
“Please specify a VI Server name eg….
powershell.exe vCheck.ps1 vmcpesuwp01lc”
But it doesnt deliver email to my mailbox.
Please can anyone of you let me what i am doing wrong. I am running the sciprts on VC itself. my VC configuration is 2.5 U2 and windows powershell.
I have enter SMTP address in my VC mgmt server configuration.
Thanks
Has anyone got this owrking on Windows 2k8 as a scheduled task? I can get the script to execute with the scheduler, but it fails to connect to the VC. I receive the email advising of the failure to connect-VIserver, so I’m happy SMTP is working at least!
The bit of the script I have looked at is line 702 – 716. I noticed the ‘fix for scheduled tasks’ and the $apppath syntax is for W2K3. Does this need to be modified for W2K8, or does the symbolic link that 2K8 keeps for backwards compatibilty take care of it?
The script runs normally when executed from a batch file, but the scheduler doesn’t seem to pass the connection string properly.
Hi I can run the script locally on the vCenter server and manually but I do receive the following warnings in the display:
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
I also get:
Warning: Unable to populate snapshot size due to insufficient permission.
The account I am using has local admin privileges and also has the administrators role in vCenter itself.
Also when I send the email I get the email but with an error pertaining to Adjusting Connection Information section I have manually specified the credentials as suggested with the same account (local administrator and administrators role in vCenter) but I still get the problem.
Obviously I appreciate it suggests a credentials problem. But can someone clarify what credentials are needed as I thought that would suffice.
Would very much appreciate some advice on this as it would be extremely useful to us if I can get this working.
Thanks Darren
Spoke to soon…
Still getting the error now at line 1 char 5.
🙁
Ooops…
Thanks Robert 🙂
Hi Rich,
You have to change the first and second lines of your code. The param line should always be the first line. The Add-PSSnapIn line should be after the param line.
Regards, Robert
I am struggling to get the code to run. Debugging points to the first line (actually second line) in my code:-
param ( [string] $VISRV)
I have added add-pssnapin VMware.VimAutomation.Core as line 1 in my script.
Error is :-
The term ‘param’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At :line:2 char:5
+ param <<<< ( [string] $VISRV)
Using PS v2, PowerCLI 4 u1, on Win2k8 x64.
Hi Al
Your Website is absolutely awesome ! I often use your scripts at work or just for new ideas to create my own scripts. Your vCheck is very great, even though I have some running time issues with it. We’ve got a pretty huge environment and so the CapacityInfo part takes almost for ages to complete. So I played around with it a little and figured something out. If I simply add -IntervalSecs 7200 to the cpu.usagemhz.average and mem.consumed.average the hole part is running much faster. If I change the value to 1800 secs it gets even faster. I used measure-command and the time it takes to get the cpu values for only one host is only a third of the time it took before. Maybe this only works for me… but hopefully it helps other people too 🙂
The solution to Outlook is actually fairly simple, without going through the “Attachment hack” (+ I prefer my content directly in the e-mail, not in an attachment, makes it easier on mobile devices).
If you just stick all the CSS options into variables, and don’t use classes but only inline-styles, Outlook will parse it without a problem.
So make a variable “$css_dspheader1” with the exact content of the “dsp” and “dsphead0”, and change the ‘class=”dsp dsphead0″‘ with ‘style=”$($css_variable)”‘, so all the CSS markup is done inline, and not in those CSS styles defined at the top.
While it’s not really pretty, it doesn’t change much from the programming point-of-view, as you’ll only declare your CSS styles once, but they’ll be present multiple times in the mail.
We have multiple vcenter servers in my environment. Could the script be modified to pull data from more than one vcenter server, or would I have to run it individually against each?
Pingback: vCheck (Daily Report) script « VMtech.se
I can’t seem to make the script run as a scheduled task with windows 2008 scheduler.
the task will run but will not seem to stop. The status is alwyys on running mode even after 24 hours.
I have changed my line from:
$VIServer = Connect-VIServer $VISRV
to
$VIServer = Connect-VIServer $VISRV -cred $creds
and the settings for my scheduler are as follows.
Under program/scripts: powershell.exe
Under Add arguments (optional) -noninteractive -noprofile -command “”
Under Start in (optional): C:\Scripts\vCheck
Interesting enough if I run the command from the prompt like this:
J:\>powershell.exe -noninteractive -noprofile -command “”
It would run fine.
SO what it is that I am not doing correctly in windows 2008 scheduler ?
Pingback: ESX3.5/vCenter2.5 Slot Size Calculation For vCheck v5 « DeinosCloud
It looks like the function that should check free space on VMs actually checks just a hard drive capacity.
I’ve changed this part of code:
from
if (([math]::Round($disk.Capacity/ 1MB)) -lt $MBFree){
to
if (([math]::Round($disk.FreeSpace/ 1MB)) -lt $MBFree){
Now it makes more sense.
The following is code I wrote for just checking the free space of the C:\ drive. Enjoy.
Top Section
# Show VMs C:\ disk space check
$ShowGuestCDriveSpace = $true
Code Section:
# —- VM Disk Space – C: \ Less than x MB —-
If ($ShowGuestCDriveSpace){
Write-CustomOut “..Checking for Guests with C:\ less than $MBFree MB”
$MyCollection = @()
$AllVMs = $FullVM | Where {-not $_.Config.Template } | Where { $_.Runtime.PowerState -eq “poweredOn” -And ($_.Guest.toolsStatus -ne “toolsNotInstalled” -And $_.Guest.ToolsStatus -ne “toolsNotRunning”)}
$SortedVMs = $AllVMs | Select *, @{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks
ForEach ($VMdsk in $SortedVMs){
$Details = New-object PSObject
$DiskNum = 0
Foreach ($disk in $VMdsk.Guest.Disk){
if ($disk.DiskPath -eq “c:\” ){
if (([math]::Round($disk.FreeSpace / 1MB)) -lt $MBFree){
$Details | Add-Member -Name Name -Value $VMdsk.name -Membertype NoteProperty
$Details | Add-Member -Name “Disk$($DiskNum)path” -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name “Disk$($DiskNum)Capacity(MB)” -MemberType NoteProperty -Value ([math]::Round($disk.Capacity/ 1MB))
$Details | Add-Member -Name “Disk$($DiskNum)FreeSpace(MB)” -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
$DiskNum++
$MyCollection += $Details
}
}
}
}
If (($MyCollection | Measure-Object).count -gt 0) {
$MyReport += Get-CustomHeader “VMs with C:\ less than $MBFree MB : $($MyCollection.count)” “The following guests have a C:\with less than $MBFree MB Free. If the C:\ disk fills up it may cause issues with the guest Operating System”
$MyReport += Get-HTMLTable $MyCollection
$MyReport += Get-CustomHeaderClose
}
}
Mine is also stuck at checking capacity info and has been for a long time. A bug maybe?
Found this sript took a long time to run but once completed highlighted a number of issues with our environment which we were previously unaware.
A must for any VMware Administrator.
If you want the script to use the credentials you supply that are stored in the mycred.crd change the lines 701 and 712 that read
$VIServer = Connect-VIServer $VISRV
to
$VIServer = Connect-VIServer $VISRV -cred $creds
I am also having the “WARNING: Unable to populate snapshot size due to ‘unsiffucient’ permissions.” despite having the appropriate permissions and running PowerCLI v4.1 – I have cleanly installed everything to a new machine and attempted to run it from there with exactly the same results – Help would be appreciated with this.
I had the same issue, my server is 64-bit Windows 2008 R2 and vCenter 4.1 and had issues trying to get the script to run on the vCenter server locally. I tried:
Made sure UAC was disabled
Made sure RemoteSigned policy was enabled
Made sure my account was an Administrator on the server and in vCenter
Ran command in PowerShell (32-bit) both as my account and “Run as administrator”
Ran command in PowerShell (64-bit) both as my account and “Run as administrator”
Ran command in VMware vSphere PowerCLI (32-bit) both as my account and “Run as administrator”
Ran command in VMware vSphere PowerCLI (64-bit) both as my account and “Run as administrator”
Each time I made sure to use the vCenter server and used several variations like WINs name, FQDN, localhost, and IP.
I was never able to get the script to report more than 1 host even though I have 18 in vCenter.
Only way I got this to work was to run the script remotely from my Windows 7 32-Bit VM.
When I say vSphere, I mean vCenter!
“””What are the minimum rights the account running the script requires on the vSphere server?”””