PowerCLI Cmdlet "Get-VIMachineCertificate" Fails to Fetch vCenter and ESXi Certificates in VCF PowerCLI 9.0
search cancel

PowerCLI Cmdlet "Get-VIMachineCertificate" Fails to Fetch vCenter and ESXi Certificates in VCF PowerCLI 9.0

book

Article ID: 402738

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

In VCF PowerCLI 9.0, the "Get-VIMachineCertificate" cmdlet parameters (`-EsxOnly` and `-VCenterOnly`) do not function as expected, returning zero(0) when attempting to retrieve certificates for ESXi hosts or vCenter Server.

Environment

VMware vCenter Server 8.x
VMware vCenter Server 9.x
VCF PowerCLI 9.0

Resolution

This is a known issue, and a fix is planned for the VCF 9.0 P01 release.

In the interim, the following workarounds can be used to fetch ESXi and vCenter certificates separately:

Workaround:

Connect to vCenter Server:
$conn = Connect-VIServer -Server <vcenter-server> -User <username> -Password <password>

Get only vCenter Certificate:
$conn.GetClient().CertificatesService.GetVcMachineCertificates()

Get all ESXi(s) Certificates:
$conn.GetClient().CertificatesService.GetHostsMachineCertificates($null)

Get Single ESXi Certificate:
$vmhost = Get-VMHost -Name <esxname>
$conn.GetClient().CertificatesService.GetHostsMachineCertificates([VMware.VimAutomation.ViCore.Interop.V1.Inventory.VMHostInterop[]]@($vmhost))