vCheck-vSphere
vCheck-vSphere copied to clipboard
QUESTION : How to use multiple vCenters ?
Hello,
i cannot fill more than one vCenter in GlobalVariables.ps1 file. for example this doesnt run fine : Please Specify the IP address or Hostname of the server to connect to $Server = "SRV1,SRV2,SVR3,SRV4"
By the way the "Connect-VIServer SRV1,SRV2,SVR3,SRV4" command is supported.
How can i fill multiple vCenters to get merged report of all my vCenters ? Thanx for help,
A couple of problems with this. Connect-VIServer can take an array of servers, what you're passing is a string.
If you change to $Server = "SRV1","SRV2","SVR3","SRV4"
, that will stop Connect-VIServer complaining.
Secondly, you will need to remove or modify the following section as Connect-VIServer will be returning an array of connections rather than a single connection: if (-not $VIConnection.IsConnected) { Write-Error $pLang.connError }
You will also have to check if DefaultVIServerMode is set to multiple (this is the default), otherwise it will just query the last connected server.
I haven't had a chance to test any of this, but should in theory work I believe. Probably something we need to consider in a future release.
We have multiple large and small vCenter environments so we prefer having one report per vCenter. It's easier to read through and prioritize production versus nonprod environments. There is one scheduled task per vCenter.
I dont want to raise another issue so I will attach myself there. In the latest release (6.22-alpha6) I am having troubles with executing vCheck from a single folder to a number (12 to be exact) of vCenters. Is there any way I can start vCheck with the same set of plugins for a number of vCenter servers? I tried doing this with job file (with the GlobalVariables file defined only, no Plugins section) but it fails. I could try to add a new parameter into the vCheck.ps1 itself but I dont want to change it so I dont need to amend the script every time i update it.
The job file does work for this- this is exactly what I use against our vCenters at work :)
I essentially have a job file similar to the one below for each vCenter:
<vCheck>
<globalVariables>GlobalVariables-server1.ps1</globalVariables>
</vCheck>
And then just a seperate GlobalVariables.ps1 for each vCenter as well obviously.
I am not sure if I get it right. Your job file is ps1 instead of xml? Also could you advise how it should look like if I want the job file to define GlobalVariables file only, not plugins? When I put it as below I am getting a lot of errors (path related):
Ah sorry- looks like Github screwed up the formatting on the XML I embedded. Should be able to see it now. And yes, it is an XML file not PS1
My job file is located in the vCheck Directory, and the "Start in" path of my scheduled task is also pointing to the vCheck directory.
My job file looks exactly the same as your:
<vCheck>
<globalVariables>GlobalVariables-XYZ.ps1</globalVariables>
</vCheck>
I dont have anything in the <plugins>
section. When I exectute the vCheck:
PowerCLI > .\vCheck.ps1 -job .\jobXYZ.xml
I am getting an error saying:
cannot bind parameter 'path' because it is an empty string
That seems to be logical as the <plugins path=" ">
part does not exist. Any idea whats wrong?
Yeah OK, I can see the error you are getting. It shouldn't cause anything to fail though- you will get the error, but will fall back to using the default path if there are no plugins defined in the XML. Because mine is scheduled, i never saw the error.
I'll add another check to get rid of the error though- thanks for picking that up.
I am definitely very interested in possibly automating this for multiple vCenters. What about using VCO as a solution? I suppose that would not really address the issue but I think it would achieve the desired result.
Would people be interested in having the server passed in on the command line? What I have done is moved $Server out of the Connection Plugin and placed it in the param of vCheck.ps1 and setting a default value for the server. This will work for users that only have one server so nothing would change on how they run vCheck. But allows users with multiple servers to pass in on the command line a server to override the default.
Example vCheck.ps1 -Server vcServer02
param ( [Switch]$config,
[ValidateScript({ Test-Path $_ -PathType 'Container' })]
[string]$Outputpath=$Env:TEMP,
[ValidateScript({ Test-Path $_ -PathType 'Leaf' })]
[string]$job,
[string]$Server = "vcServer01"
)
Added the code for command line parameters Server and DataCenter to DEV. See Pull Request #489
This runs against a single Server but no need to create a different job file for each server.
What about generating the config file into an XML ? We could then generate an XML for each connection and pass that to the script. This way we could have different set of config for each VCenters vCheck.ps1 -vcenter vcenter1.xml
Any update on this. Still having the issue with release 6.24 $Server = "ipaddress1","ipaddress2" # addresses change to protect the innocent The first complaint is Cannot bind parameter 'Port'.... I have tried with :443 as well as not specifying any port.
@jkavanagh58 Looking at the plugin, I'm not sure the advice @Sneddo provided is 100% workable. The 00 Connection Plugin for vCenter has a lot of assumptions about the $Server variable being a single item, as opposed to an array -
$VIServer = ($Server -Split ":")[0]
if (($server -split ":")[1]) {
$port = ($server -split ":")[1]
}
This is going to explicitly mess up any attempt to utilize multiple viCenters. If I put two items in my array, it will try to bind the second item to the $port variable:
$Test= @("vc01","vc02")
($test -split ":")
vc01
vc02
I think additional logic would need to be added to handle this more properly. I think the original request, which specified using this setting as a string (not storing it as an array in the configuration) is more consistent with the rest of the vCheck utility. For instance, the email addresses are stored as a comma separated string. The email settings just benefit that the System.Net.Mail.MailMessage methods being used to add these to the message happen to accept a comma separated string:
$msg.CC.Add($EmailCc)
I would also personally like to have vCheck run once for each of a configured list of vCenters, and send a separate report for each. I will be working on modifying the script to see if I can get it to accommodate this. I think if we take the vCenters as a comma separated string, we can always do a split, and then loop through each one for the report. But, we could also have it prompt as to whether you want all in one report, or if you want multiple reports (one per vCenter).