Set-VIMachineCertificate Command | Vmware PowerCLI Reference

Set-VIMachineCertificate

This cmdlet sets a machine SSL certificate to a vCenter Server instance or a connected ESXi host.By default, the certificate is set to the vCenter Server instance. If you want to set the certificate to a specific ESXi host, you must use the VMHost parameter.The result from the command is the updated vCenter Server or ESXi entity with the certificate that was set.To use this cmdlet, you must connect to vCenter Server through the Connect-VIServer cmdlet.IMPORTANT: When you change the machine SSL certificate of a vCenter Server system, a restart is triggered.

Syntax

Set-VIMachineCertificate
[-Key < AsymmetricAlgorithm > ]
[-PemCertificate < String > ]
[-PemKey < String > ]
[-Server < VIServer > ]
[-X509Certificate < X509Certificate > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
optional Key AsymmetricAlgorithm named
Specifies the private key as AsymmetricAlgorithm type of the certificate that you want to set. Note: To use this parameter, you must have PowerShell version 7.1 or later.
optional PemCertificate String named
Specifies a certificate in PEM format to be set as the machine SSL certificate to a vCenter Server instance or an ESXi host.
optional PemKey String named
Specifies the private key in PEM format of the certificate that you want to set to a vCenter Server system.
optional Server VIServer named
optional X509Certificate X509Certificate named
Specifies a certificate as an X509Certificate object to be set as the machine SSL certificate to a vCenter Server instance or an ESXi host.
Set-VIMachineCertificate
-VMHost < VMHost >
[-PemCertificate < String > ]
[-Server < VIServer > ]
[-X509Certificate < X509Certificate > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
VMHost VMHost named
  • pipeline
Specifies the ESXi host to which you want to set a machine SSL certificate.
optional PemCertificate String named
Specifies a certificate in PEM format to be set as the machine SSL certificate to a vCenter Server instance or an ESXi host.
optional Server VIServer named
optional X509Certificate X509Certificate named
Specifies a certificate as an X509Certificate object to be set as the machine SSL certificate to a vCenter Server instance or an ESXi host.

Output

ViMachineCertificateInfo

Examples

Example 1

$certificatePem = Get-Content cert.pem -Raw
Set-VIMachineCertificate -PemCertificate $certificatePem

Sets the certificate from the cert.pem file to the vCenter Server system.

Example 2

$certificatePem = Get-Content cert.pem -Raw
Set-VIMachineCertificate -PemCertificate $certificatePem -VMHost 'MyHost'

Sets the certificate from the cert.pem file to the 'MyHost' ESXi host.

Related Commands

VIMachineCertificate

This cmdlet retrieves information about the machine SSL certificates in a vCenter Server environment.

This cmdlet sets a machine SSL certificate to a vCenter Server instance or a connected ESXi host.

VIMachineCertificateSigningRequest

This cmdlet generates a new Certificate Signing Request (CSR) for a vCenter Server system or an ESXi host.