I was looking for a script that could give a overview of all my VDI using a vGPU. I found one here https://powercli.ideas.aha.io/ideas/PCLI-I-51, but this function was not enough for me. So I used some parts from this script and added some extra information to it.
The things I added to the script were HostName, CardType, CardId. My goal is to create a capacity script, but as always you need to create the basics first. And I hope this is a good start to calculate the capacity in the end.

Function Get-vGPUOverview{
Param (
$Cluster
)
#variables
$GPUs = 0..3 #number of GPU cards per host
$vmhosts = Get-VMHost -Location $Cluster
$output=@()
foreach($vmhost in $vmhosts){
$VMhost = Get-VMhost $VMhost
$VMs = get-vmhost -name $vmhost | get-vm
foreach ($g in $GPUs){
$VDIs = $vmhost.ExtensionData.Config.GraphicsInfo[$g].Vm
if(!$VDIs){
$object = New-Object PSObject
Add-Member -InputObject $object NoteProperty HostName $vmhost.Name
Add-Member -InputObject $object NoteProperty CardType $vmhost.ExtensionData.Config.GraphicsInfo[$g].DeviceName
Add-Member -InputObject $object NoteProperty CardId $vmhost.ExtensionData.Config.GraphicsInfo[$g].PciId
Add-Member -InputObject $object NoteProperty VDIName 'NoVDIs'
Add-Member -InputObject $object NoteProperty ProfileType 'NoProfiles'
$output+= $object
}
foreach($vdi in $VDIs){
$vm = $VMs | ? {$_.id -match $vdi.Value}
$vGPUDevice = $VM.ExtensionData.Config.hardware.Device | where {$_.Backing.Vgpu}
$ProfileType = $vGPUDevice.Backing.Vgpu
$object = New-Object PSObject
Add-Member -InputObject $object NoteProperty HostName $vmhost.Name
Add-Member -InputObject $object NoteProperty CardType $vmhost.ExtensionData.Config.GraphicsInfo[$g].DeviceName
Add-Member -InputObject $object NoteProperty CardId $vmhost.ExtensionData.Config.GraphicsInfo[$g].PciId
Add-Member -InputObject $object NoteProperty VDIName $vm.Name
Add-Member -InputObject $object NoteProperty ProfileType $ProfileType
$output+= $object
}
}
}
$output | sort HostName,CardId | ft
}