VMware Cloud Foundation (VCF) 9.0 has introduced a number of enhancements when consuming vGPU and DirectPath Profiles, which are available in both the vSphere UI and vSphere API for automation purposes. While answering some vSphere API questions from a colleague regarding vGPU and DirectPath Profiles, I figured it would be useful to share the vSphere API specifics in how to use the API to retrieve these resources and better yet, some code that you can use immediately!
vGPU Profiles
When adding a PCI device to a VM using the vSphere UI, a list of available vGPU Profiles will be displayed for users to select from as shown in the screenshot below.

To get the list of available vGPU Profiles, we will be using the QueryConfigTarget() API which can be scoped at either the vSphere Cluster or an individual ESXi host level. Once you have identified your resource scope level, we will need to get a reference to the EnvironmentBrowser manager which provides the actual API functionality. The result of the API is ConfigTarget object which will return a number of attributes on what the scoped resource can support and for our specific use case, we will be focusing on following properties:
- DynamicPassthrough - DirectPath Enabled Devices
-
VgpuProfileInfo - vGPU Enabled Devices
-
VendorDeviceGroupInfo - Device Group Enabled Devices
To demonstrate the use of this vSphere API, I have created the following PowerCLI sample get_vgpu_profiles.ps1 which will output the following simliar to the vSphere UI:

Note: vGPU Profiles can be accessed pre-9.0 with following requirements: DynamicPassthrough requires vSphere 7.0, VgpuProfileInfo requires 7.0 Update 3 and VendorDeviceGroupInfo requires 8.0
DirectPath Profiles
If you have created DirectPath Profiles, they will appear under Policies and Profiles->DirectPath Profiles as shown in the screenshot below.

A new DirectPathProfileManager object is what we will used to interact with DirectPath profiles and specifically the DirectPathProfileManagerList() API method.
To demonstrate the use of this vSphere API, I have created the following PowerCLI sample get_directpath_profiles.ps1 which will output the following simliar to the vSphere UI:
DirectPath Profile Utilization
To view the utilizations of all your DirectPath Profiles, select your vSphere Cluster and navigate to Monitor->DirectPath Profiles Utilizations as shown in the screenshot below.

Simliar to listing all DirectPath Profiles, we will be using the DirectPathProfileManager object but this time we will use the DirectPathProfileManagerQueryCapacity() API to return overall usage information.
To demonstrate the use of this vSphere API, I have created the following PowerCLI sample get_directpath_profile_usage.ps1 which will output the following simliar to the vSphere UI:


Thanks for the comment!