VMware Cloud Community
AlexanderNabok1
Contributor
Contributor

run vCheck for mutliple VC

Hi,

I need to run vCheck for multiple vCenters (18 to be exact) having one report per vCenter.

Can somebody suggest me how can I achieve this without creating separate directory with all vCheck plugins for each vCenter.

Thank you

26 Replies
LucD
Leadership
Leadership

The vCheck.ps1 script accepts a number of parameters, one of these is the Job parameter.

The job parameter points to an XML file (default plugins.xml).

In this XML file you can define the plugin list.

The first plugin (plugin 00) contains the server to which to do the Connect-VIServer.

So you could run several invocations of vCheck.ps1 with different vaules for the Job parameter.

Each XML file would point to a different plugin_00, while the rest of the plugins stays the same.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
AlexanderNaboki
Contributor
Contributor

Could you please provide an example of such XML file? I cannot find documentation on that.

Reply
0 Kudos
LucD
Leadership
Leadership

When you extract vCheck to your drive, there is a default one, called plugins.xml, in the vCheck directory.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
AlexanderNaboki
Contributor
Contributor

Yes, I got this.

I just don't understand what exactly should I change in this file and in GlobalVariables.ps1, 00 Initialize to get this done.

Do you have any instructions? or documentation.

Thank you

Reply
0 Kudos
nullifi
Contributor
Contributor

I'm not sure if this is the intended way, but I created different xml files containing only this, with the filename changed for each server. I named it config-server1.xml, etc:

<vCheck>

     <globalVariables>GlobalVariables-Server1.ps1</globalVariables>

</vCheck>

I then copied the default GlobalVariables.ps1 script and made the minor modification of adding a global variable: $Global:VCServer="server1"

I then modified the 00 connection plugin to set $Server = $Global:VCServer.

I am sad that I had to modify the 00 file, as I had hoped that it pulled data in from global variables but it doesn't appear that it does. With the job xml file not specifying plugins, it uses the default plugin list that is available locally, so it behaves the same as running it without the -job parameter.

treemon
Contributor
Contributor

Hi Nullifi

I tried your method.

Its great to be able to specify the job upfront and get an output based on that but there is still only 1 report per email.

Does anyone have any idea how to have an email sent, which will have 1 html attachment per VC

So that a single report can be run against several vcs at the same time and you end up with an email with as many attachments?

Thanks for the help so far Smiley Happy

Reply
0 Kudos
LucD
Leadership
Leadership

What I do to produce reports for all my vCenters in one run (with one email), is the following.

1. Create a separate Plugin00, one for each vCenter (in this file you specify the vCenter and assign it to the $server variable)

Also define in here that this vCheck run should just create the HTML file, but not send it.

vc1-ps1.png

2. Create an XML file for each vCenter. The content of these XML files can be the same, except for the pointer to Plugin00, which should be the vCenter specific one.

The example just contains the bare minimum of plugins, you can have more.

vc1-xml.png

3. Use a script to run vCheck against all the vCenters (2 in the example), and when completed send an email with all the HTML files attached

.\vCheck.ps1 -job vc1.xml -Outputpath .\Reports

.\vCheck.ps1 -job vc2.xml -Outputpath .\Reports

$mailAddr = 'me@domain.com'

$smtp = 'mail.domain.com'

$attchments = Get-ChildItem -Path .\Reports | Select -ExpandProperty FullName

Send-MailMessage -From $mailAddr -To $mailAddr -Subject 'vCheck Reports' -SmtpServer $smtp -Attachments $attchments


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

fcocquyt16
Contributor
Contributor

No - had not seen that Smiley Happy

thanks,

buys LucD a beer

has anyone coded the {vcenter list} and {plugin list} as parameters to vcheck before I go off and do it?

thanks

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

hmm - it runs fine - then throws an error on "

Get-ReportHTML : The term 'Get-ReportHTML' is not recognized"


seems to be defined in styles...?

[12:22:46] Collecting VM Objects

[12:22:47] Collecting VM Host Objects

[12:22:47] Collecting Cluster Objects

[12:22:47] Collecting Datastore Objects

[12:22:48] Collecting Detailed VM Objects

[12:22:50] Collecting Template Objects

[12:22:51] Collecting Detailed VI Objects

[12:22:51] Collecting Detailed Alarm Objects

[12:22:51] Collecting Detailed VMHost Objects

[12:22:52] Collecting Detailed Cluster Objects

[12:22:52] Collecting Detailed Datastore Objects

[12:22:52] Collecting Detailed Datastore Cluster Objects

[12:22:53] ..finished calculating Connection settings for vCenter by Alan Renouf

v1.7 [2 of 4]

[12:22:53] ..start calculating General Information by Alan Renouf, Frederic Mart

in v1.2 [3 of 4]

[12:22:55] ..finished calculating General Information by Alan Renouf, Frederic M

artin v1.2 [3 of 4]

[12:22:55] ..start calculating Snapshots Oversize by Raphael Schitz, Shawn Maste

rson v1.3 [4 of 4]

[12:23:02] ..finished calculating Snapshots Oversize by Raphael Schitz, Shawn Ma

sterson v1.3 [4 of 4]

Get-ReportHTML : The term 'Get-ReportHTML' 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 E:\vmware\vCheck-snapreport\vCheck.ps1:748 char:13

+ $MyReport = Get-ReportHTML

+             ~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (Get-ReportHTML:String) [], Comm

   andNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

Ok I manually added a source .style - now to solve the first error - now I'm getting:

PowerCLI E:\vmware\vCheck-snapreport> .\vCheck.ps1 -job .\sanssnte01vcn55.xml -outputpath .\report

E:\vmware\vCheck-snapreport\vCheck.ps1 : Cannot validate argument on parameter

'Outputpath'. The "Test-Path $_ -PathType 'Container'" validation script for

the argument with value ".\report" did not return true. Determine why the

validation script failed and then try the command again.

At line:1 char:53

+ .\vCheck.ps1 -job .\sanssnte01vcn55.xml -outputpath .\report

+                                                     ~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [vCheck.ps1], ParameterBindingV

   alidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,vCheck.ps1

what is that complaint - another variable not sourced?

thanks

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

Ok the report files are generated - time to send them - BUT an error:

PowerCLI E:\vmware\vCheck-snapreport> .\sendsnapreport.ps1

Send-MailMessage : Access to the path

'E:\vmware\vCheck-snapreport\Report\archives\sanssnte03vcn55.san.ssnsgs.net'

is denied.

At E:\vmware\vCheck-snapreport\sendsnapreport.ps1:5 char:1

+ Send-MailMessage -From $mailAddr -To $mailAddr -Subject 'vCheck Reports'

-SmtpSe ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~

    + CategoryInfo          : NotSpecified: (:) [Send-MailMessage], Unauthoriz

   edAccessException

    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Pow

   erShell.Commands.SendMailMessage

but I can write to it fine:

PowerCLI E:\vmware\vCheck-snapreport> md E:\vmware\vCheck-snapreport\Report\Arch

ives\sanssnte03vcn55.san.ssnsgs.net\t

    Directory:

    E:\vmware\vCheck-snapreport\Report\Archives\sanssnte03vcn55.san.ssnsgs.net

Mode                LastWriteTime     Length Name

----                -------------     ------ ----

d----        11/25/2016   9:09 AM            t

Help me LucD

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

Getting close Smiley Happy - I'll back it up to the original request - "how to run vcheck on a subset of the plugins over a series of vcenters"

Can the author provide an example vCheck report running against a set {vcenter1, vcenter 2,...vcenterN}

foreach vcenter {some list of vcenters}

     execute a plugin from a list (snapshots in this case)

end

#thanks

Reply
0 Kudos
LucD
Leadership
Leadership

Do you have a Plugin00 (connection) and an XML with the desired plugin for each vCenter in the list?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

Ok, seems to be working fine up until the 9th or 10th vcenter 00 Connection plugin.ps1

(I tested 2 vcenters at a time, they all finished and reported - but then put all the 00 Connection plugin.ps1's  and its hanging or throwing an error like out of memory after sitting there for 25 minutes - and this vcenter returned fine in an earlier test run - I think the previous vcenter connections are not disconnected and could be responsible for the hangs/memory errors?)

[18:48:02] Adding Custom properties

[18:48:02] Collecting VM Objects

[18:48:08] Collecting VM Host Objects

[18:48:15] Collecting Cluster Objects

[18:48:16] Collecting Datastore Objects

[18:48:17] Collecting Detailed VM Objects

[18:48:38] Collecting Template Objects

[18:48:46] Collecting Detailed VI Objects

[18:48:47] Collecting Detailed Alarm Objects

[18:48:53] Collecting Detailed VMHost Objects

[18:49:23] Collecting Detailed Cluster Objects

[18:49:24] Collecting Detailed Datastore Objects

[18:49:27] Collecting Detailed Datastore Cluster Objects

[18:49:27] ..finished calculating Connection settings for vCenter by Alan Renouf

v1.7 [10 of 13]

[18:49:27] ..start calculating Snapshot Information by Alan Renouf, Raphael Schi

tz v1.4 [11 of 13]

Get-View : 11/28/2016 7:15:54 PM    Get-View        Exception of type

'System.OutOfMemoryException' was thrown.

At E:\vmware\vCheck-snapreport\Plugins\60 VM\02 Snapshot Information.ps1:87

char:10

+             $vm = Get-View $_.Entity

+                   ~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-View], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio

   n.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView

thanks!

Reply
0 Kudos
LucD
Leadership
Leadership

The vCheck script creates some rather big variables, and unfortunately doesn't clean up.

If you do multiple vCheck runs in a row, the PowerShell might get out of memory (the message you are seeing).

PowerShell uses some default settings, one of these is the default memory (since PS v3 this is 1 GB) for a session.

You can check with

Get-Item WSMan:localhost\Shell\MaxMemoryPerShellMB

And you can change the default. For example to 2 GB (provided the station you run the script has sufficient resources)

Set-Item WSMan:localhost\Shell\MaxMemoryPerShellMB 2048


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

Ok, I increased it to 2Gb and got "failed to start thread" - (this is failing on our largest vcenter):

[08:31:52] Adding Custom properties

[08:31:52] Collecting VM Objects

[08:31:57] Collecting VM Host Objects

[08:32:07] Collecting Cluster Objects

[08:32:09] Collecting Datastore Objects

[08:32:10] Collecting Detailed VM Objects

[08:32:28] Collecting Template Objects

[08:32:31] Collecting Detailed VI Objects

[08:32:33] Collecting Detailed Alarm Objects

[08:32:38] Collecting Detailed VMHost Objects

[08:33:31] Collecting Detailed Cluster Objects

[08:33:32] Collecting Detailed Datastore Objects

[08:33:40] Collecting Detailed Datastore Cluster Objects

[08:33:40] ..finished calculating Connection settings for vCenter by Alan Renouf

v1.7 [10 of 14]

[08:33:40] ..start calculating Snapshot Information by Alan Renouf, Raphael Schi

tz v1.4 [11 of 14]

Get-View : 11/29/2016 8:55:44 AM    Get-View        Thread failed to start.

At E:\vmware\vCheck-snapreport\Plugins\60 VM\02 Snapshot Information.ps1:87

char:10

+             $vm = Get-View $_.Entity

+                   ~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-View], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomatio

   n.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView

--

Any ideas?

thanks

Reply
0 Kudos
LucD
Leadership
Leadership

The issues always seem to be appear with plugin 02 Snapshot Information.
Did you already try leaving that plugin out?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

When I leave that plugin out I get new & different errors from the same vcenter - but it ends up completing and sending the report.

Here are the errors - maybe they give a clue why plugin 02 is hanging on this vcenter?:

[10:07:57] Adding Custom properties

[10:07:57] Collecting VM Objects

[10:08:08] Collecting VM Host Objects

[10:08:15] Collecting Cluster Objects

[10:08:16] Collecting Datastore Objects

[10:08:17] Collecting Detailed VM Objects

[10:08:31] Collecting Template Objects

[10:08:34] Collecting Detailed VI Objects

[10:08:37] Collecting Detailed Alarm Objects

[10:08:42] Collecting Detailed VMHost Objects

[10:09:38] Collecting Detailed Cluster Objects

[10:09:41] Collecting Detailed Datastore Objects

[10:09:45] Collecting Detailed Datastore Cluster Objects

[10:09:45] ..finished calculating Connection settings for vCenter by Alan Renouf

v1.7 [10 of 13]

[10:09:45] ..start calculating VMs needing snapshot consolidation by Luc Dekens,

Frederic Martin v1.2 [11 of 13]

Exception calling "Add" with "2" argument(s): "Item has already been added.

Key in dictionary: 'HostSystem-host-29'  Key being added: 'HostSystem-host-29'"

At E:\vmware\vCheck-snapreport\Plugins\60 VM\45 VMs needing snapshot

consolidation.ps1:5 char:17

+ $HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)}

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ArgumentException

Exception calling "Add" with "2" argument(s): "Item has already been added.

Key in dictionary: 'HostSystem-host-49'  Key being added: 'HostSystem-host-49'"

At E:\vmware\vCheck-snapreport\Plugins\60 VM\45 VMs needing snapshot

consolidation.ps1:5 char:17

+ $HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)}

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ArgumentException

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 E:\vmware\vCheck-snapreport\Plugins\60 VM\45 VMs needing snapshot

consolidation.ps1:5 char:17

+ $HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)}

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ArgumentException

Exception calling "Add" with "2" argument(s): "Item has already been added.

Key in dictionary: 'HostSystem-host-29'  Key being added: 'HostSystem-host-29'"

At E:\vmware\vCheck-snapreport\Plugins\60 VM\45 VMs needing snapshot

consolidation.ps1:5 char:17

+ $HostsViews | %{$htabHostVersion.Add($_.MoRef,$_.config.product.version)}

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ArgumentException

Reply
0 Kudos
Trammell
Contributor
Contributor

Also define in here that this vCheck run should just create the HTML file, but not send it.

LucD

I am unsure how to set it for not sending the file within the 00 Plugin.ps1 script. I don't see any mail code inside of it. Did you mean to edit the GlobalVaribles.ps1 $SendEmail = $false?

Reply
0 Kudos