apiVersion: batch/v1
kind: Job
metadata:
  name: vsphere-script
  labels:
    # Make this Job match the binding!
    role: vsphere-job
spec:
  template:
    metadata:
      labels:
        # So it's easier to list the Pods
        role: vsphere-job
    spec:
      restartPolicy: Never
      containers:
      - name: dump-events
        image: docker.io/vmware/powerclicore
        command: ["pwsh", "-Command"]
        args:
        - |
          # Log into the VI Server
          Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
          Connect-VIServer -Server ([System.Uri]$env:VC_URL).Host -User $env:VC_USERNAME -Password $env:VC_PASSWORD

          # Get Events and write them out.
          Get-VIEvent | Write-Host
