VCF Automation Blog

from Stefan Schnell

Connect vCenter Server in HOL with PowerCLI


<#
 # @module de.stschnell
 # @version 0.4.0
 # @runtime powercli:13-powershell-7.4
 # @memoryLimit 384000000
 # @outputType Properties
 #>

<#
 # Example to show how to connect vCenter server system in HOL.
 # Choose the runtime environment PowerCLI 13 (PowerShell 7.4).
 #
 # Checked with VMware Aria Automation 8.5.1, 8.12.0, 8.16.2
 # and 9.0.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!"
   #>

  <#
   # Access data for HOL with release 8.16.2
   #
   # Connect-VIServer -Server vcenter-mgmt.vcf.sddc.lab -Port 443 `
   #   -User "administrator@vsphere.local" -Password "VMware123!"
   #>

   # Access data for HOL with release 9.0.0
   Connect-VIServer -Server vc-mgmt-a.site-a.vcf.lab -Port 443 `
     -User "administrator@vsphere.local" `
     -Password "VMware123!VMware123!"

  $Hosts = Get-VMHost

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

  $output = @{status = "done"}

  return $output

}

get version of the rhino engine in aria automation 8