alanrenouf / vCheck-vSphere

vCheck Daily Report for vSphere
MIT License
732 stars 326 forks source link

-Job parameter not working #654

Open JLogan3o13 opened 5 years ago

JLogan3o13 commented 5 years ago

I have just downloaded the latest version. I then went through the -GUIConfig and saved the file off to "vCheckSettingsOK.xml" (as I planned to have a couple different ones). When I attempt to run it, however, like so:

PS D:\Scripts\vmware\vCheck\vCheckOK> .\vCheck.ps1 -job "vCheckSettingsOK.xml" -Outputpath .\Reports

I get an immediate error out of vCheck.ps1:

Test-Path

: Cannot bind argument to parameter 'Path' because it is null. At D:\Scripts\vmware\vCheck\vCheckOK\vCheck.ps1:745 char:16 if (Test-Path $jobConfig.vCheck.globalVariables) {

  • CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingValidationException
  • FullyQualifiedErrorId ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCommand

It appears to enter the If statement on line 741 of vCheck just fine, but the $jobConfig object does not seem to be created. It appears that the if statement that should cause it to default to the GlobalVariables.ps1 is not working, as the next error indicates:

Get-Content : Cannot bind argument to parameter 'Path' because it is null. At D:\Scripts\vmware\vCheck\vCheckOK\vCheck.ps1:797 char:21

  • $file = Get-Content $GlobalVariables
  • CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand

I did confirm that the Global Variables script is in the directory. So I am unsure, first off, why it is not finding the settings XML I have in the same directory. If I, in a separate script, simply do this, it works:

$ScriptPath = (Split-Path ((Get-Variable MyInvocation).Value).MyCommand.Path) Test-Path "$($ScriptPath)\GlobalVariables.ps1"

But does not seem to do so in the vCheck script. Secondly, if it doesn't find the XML file, why is it not defaulting to the GlobalVariables.ps1? I added this to the lines right after the if block, and it comes back blank:

Write-Host "Global Variables Should be $($GlobalVariables)"

Just curious if I am missing something.

JLogan3o13 commented 5 years ago

Just an update to this, I can successfully create a folder for each vCenter, run the -config parameter and then run each vCheck in sequence, sending a single mail. My preference, of course, would be a single folder with three XML files.