VMware Cloud Community
fcocquyt16
Contributor
Contributor

foreach vcenter {report vcheck plugin xyz}

Happy Thanksgiving (I'm Canadian - ours happened in October) - but I digress (sorry, still thankful for your expert help Smiley Happy

I am looking to re-use the awesome vcheck code (plugins) across a set of vcenters

As an example, I'd like to iterate over the set of vcenters and use the plugin "Snapshot oversize"

the pseudocode - actually have code for another purpose for the loop over the vcenters looks like this:

$vcl = @("vcenter1", 

"vcenter2", "vcenter3", "vcenter4",

"lastvcenter")

foreach ($vcenter in $vcl)

{

  connect-viserver $vcenter

{do plugin "64 Snapshot Oversize.ps1" | += $report (some formatting with vcenter header) }

disconnect $vcenter

}

email $report

So my request is specific for a snapshot report - but we could all benefit (I know I could) seeing how to re-use any vcheck plugin code in this way across vcenters

(this would run as a scheduled daily job from a centralized windows VM)

thanks!

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

Did you already see Re: run vCheck for mutliple VC ?

That's how I run vCheck against multiple vCenters, and in the XML file you specify per vCenter, or the same XML for all vCenters, which snapins you want to run


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

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

Passed the first error - now getting this:

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

utputpath .\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

Reply
0 Kudos
LucD
Leadership
Leadership

Is there a folder named Report in the location where you launch the script?


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

Reply
0 Kudos
fcocquyt16
Contributor
Contributor

No,  there is not

I copied this instance from a multi-vcheck directory - will check if report is missing

thanks

Reply
0 Kudos