Hello everyone, It is time for you to update the PowerCLI module to the latest one, which is PowerCLI 12.4. The PowerCLI 12.4 is a very significant update with regards to how you will work with the REST APIs. Until now, we have had two major vSphere API bindings available for PowerCLI, and these are-
- Get-View (SOAP API bindings)
- Get-CISService (JSON-RPC)
Both of these API bindings are quite famous and still relevant for PowerCLI users. With PowerCLI 12.4, we’re introducing additional API binding for accessing the vSphere REST APIs. The new PowerCLI API bindings significantly improve the usability of working with vSphere REST APIs and provide PowerShell native user experience.
How to use vSphere Automation API SDK Module?
Update the current PowerCLI module to PowerCLI 12.4, and it will download a new set of PowerCLI modules packaged under ‘VMware.Sdk.vSphere’. This is a new manifest module containing sub-modules for all the REST APIs available for vSphere.
REST APIs have methods to execute the API and data structures to be used as an input to the API. The new API bindings provide low-level PowerShell functions to deal with the methods and data structure.
The invoke function will be used to execute the REST methods, such as GET/PUT/POST and DELETE.
#List VM via REST API
The Initialize function will be used to create the data structure which will be used as an input for REST API. For, Example Create a Local account.
$LocalAccountsConfig = Initialize-LocalAccountsConfig -Password 'Tes$TPa$$w0Rd' -Roles 'superAdmin' #Create Account Config
$LocalAccountsCreateRequestBody = Initialize-LocalAccountsCreateRequestBody -Username 'dimilov' -Config $LocalAccountsConfig #Create Account Request Body
Invoke-CreateLocalAccounts -LocalAccountsCreateRequestBody $LocalAccountsCreateRequestBody #Create Local Account
Updated vSphere API Documentation
The vSphere API Documentation is updated with PowerCLI examples to invoke the respective REST API via PowerCLI. For example, check out the REST API documentation of Create Local Accounts, and you can find the example to invoke the same API using PowerCLI.
The new vSphere Management Module
A new module is introduced for vSphere Management. It is a PowerShell-based module backed by the newly introduced vSphere Automation API SDK modules. You can actually explore the source code of this module and understand how we have created PowerCLI cmdlets by leveraging the Invoke and Initialize functions provided by the new REST API bindings. Currently, the module contains 6 cmdlets to complement certificate management. Explore the cmdlet documentation to know more.
- Upsizing VMC SDDC
- Copy-DatastoreItem is modified to support upload/download of vmdk files from vSAN datastore
- API bindings in the Horizon module have been updated with the API features of the latest Horizon 8.3.
New PowerCLI Logo
We are updating the PowerCLI logo to adhere to the new VMware brand guidelines. You can access the new logo files from here.
To wrap this up, I would conclude that the new API bindings provide you the native PowerShell experience while working with REST APIs. Please check out the PowerCLI 12.4 release notes for more details on the improvements and bug fixes.
Certificate issue while upgrading
You may encounter a certificate error while updating the existing PowerCLI module via Update-Module, as discussed here.
This is due to the fact that the certificate we used to sign the modules was replaced with a new one from a new publisher. To resolve this issue, you may be required to delete the existing module and re-install the module with the Install-Module cmdlet.