Getting Infos for vSphere First Class Disks (FCD/IVDs)

 Was looking around yesterday for a problem I had with First Class Disk objects in vCenter that we are using via CNS in kubernetes.

There is that GUI in vCenter that will list all PVCs and infos around but that will not show the physical path especially on a vSAN Datastore.

Here is a small function I wrote that will give you something like this:

<#
.Synopsis
   This will give you information about a First Class Disk 
.DESCRIPTION
   This will give you information about a First Class Disk in vSphere. They are use e.g. for CNS Volumes. Sometimes it´s hard to find the physical Path or the VM that claimed it.
.EXAMPLE
   Get-FCDInfo -Name "pvc-e51ba680-4e93-411a-bc9e-e30d0b8870b5"
.EXAMPLE 
   Get-FCDInfo -Filename "[vsanDatastore] 78f8f95e-9cf4-9c06-fbd7-08f1eaf44c56/_00b0/_0090/eda70a68ca06471e8080ef26447145b5.vmdk"
#>
function Get-FCDInfo
{
    [CmdletBinding()]
    param 
    (
        [Parameter(ValueFromPipelineByPropertyName=$true,
        ValueFromPipeline=$true,
        Position=0)]
        [string]$Name,
        [string]$Filename
    )
    if($Name)
    {
        $VDisk = Get-VDisk | ? Name -Like $PVCName
        $Vdisk = $vdisk | select Name, CapacityGB,Filename,Attached
        $VDisk.attached = (get-vm | get-harddisk | ? Filename -eq $VDisk.Filename | Select Parent).Parent
    }
    elseif($Filename)
    {
        $VDisk = Get-VDisk | ? Filename -eq $Filename
        $Vdisk = $vdisk | select Name, CapacityGB,Filename,Attached
        $VDisk.attached = (get-vm | get-harddisk | ? Filename -eq $VDisk.Filename | Select Parent).Parent
        
    }
    $VDisk
}

To learn more about FCDs / IVDs there is a great post https://cormachogan.com/2018/11/21/a-primer-on-first-class-disks-improved-virtual-disks/

Leave a Reply