Private/Get-ComponentTypeHash.ps1

Function Get-ComponentTypeHash {
    param
    (
        [SolutionComponent]$Component,
        [hashtable]$Metadata,
        [Microsoft.Xrm.Tooling.Connector.CrmServiceClient]$Conn
    )

    <# $componentTypes = @{}
    $entity = $Metadata.Target.BySchemaName.All["solutioncomponent"]
    $att = $entity.Attributes | Where-Object { $_.LogicalName -eq "componenttype" }
    $att.OptionSet.Options | ForEach-Object { $componentTypes["$($_.Value)"] = $_.Label.UserLocalizedLabel.Label }
 
    $entity = $componentTypes["$componentType"] #>

    
    
    $query = @"
    <fetch>
  <entity name="$($component.schemaName)" />
</fetch>
"@


    try {
        $result = (Get-CrmRecordsByFetch -Conn $Conn -Fetch $query -ErrorAction Stop -WarningAction SilentlyContinue).CrmRecords
    } catch { 
        $err = $_.Exception.Message
        throw $err
    }

    $hash = $result | FetchToHash

    Write-Output $hash

}