<#
# Example to show how to connect vCenter server system in HOL.
# Choose the runtime environment PowerCLI 12 (PowerShell 7.1).
#
# Checked with VMware Aria Automation 8.5.1 and 8.12.0
#>
function Handler($context, $inputs) {
$inputsString = $inputs | ConvertTo-Json -Compress;
# Write-Host "Inputs were $($inputsString)";
Set-PowerCLIConfiguration -ParticipateInCEIP $false `
-InvalidCertificateAction Ignore -Confirm:$false;
<#
# Access data for HOL with release 8.5.1
#
# Connect-VIServer -Server vcsa-01a.corp.local -Port 443 `
# -User 'administrator@corp.local' -Password 'VMware1!';
#>
# Access data for HOL with release 8.12.0
Connect-VIServer -Server vcsa-01a.corp.vmbeans.com -Port 443 `
-User 'administrator@corp.vmbeans.com' -Password 'VMware1!';
$Hosts = Get-VMHost;
for ($i = 0; $i -lt $Hosts.length; $i++) {
Write-Host $Hosts[$i].Name;
}
$output = @{status = "done"};
return $output;
}
|