<# Begin----------------------------------------------------------------
 #
 # Example to show how to connect vCenter server system in HOL.
 #
 # Checked with vRA 8.5.1.18666
 #
 #>

function Handler($context, $inputs) {

  $inputsString = $inputs | ConvertTo-Json -Compress;
  # Write-Host "Inputs were $($inputsString)";

  Set-PowerCLIConfiguration -ParticipateInCEIP $false `
    -InvalidCertificateAction Ignore -Confirm:$false;

  Connect-VIServer -Server vcsa-01a.corp.local -Port 443 `
    -User 'administrator@corp.local' -Password 'VMware1!';

  $Hosts = Get-VMHost;

  for ($i = 0; $i -lt $Hosts.length; $i++) {
    Write-Host $Hosts[$i].Name;
  }

  $output = @{status = "done"};
  return $output;

}

# End-------------------------------------------------------------------