Private/Get-AzureADRegistrationCertificateThumbprint.ps1

function Get-AzureADRegistrationCertificateThumbprint {
    <#
    .SYNOPSIS
        Get the thumbprint of the certificate used for Azure AD device registration.
     
    .DESCRIPTION
        Get the thumbprint of the certificate used for Azure AD device registration.
     
    .NOTES
        Author: Nickolaj Andersen
        Contact: @NickolajA
        Created: 2021-06-03
        Updated: 2021-06-03
     
        Version history:
        1.0.0 - (2021-06-03) Function created
    #>

    Process {
        # Define Cloud Domain Join information registry path
        $AzureADJoinInfoRegistryKeyPath = "HKLM:\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo"

        # Retrieve the child key name that is the thumbprint of the machine certificate containing the device identifier guid
        $AzureADJoinInfoThumbprint = Get-ChildItem -Path $AzureADJoinInfoRegistryKeyPath | Select-Object -ExpandProperty "PSChildName"

        # Handle return value
        return $AzureADJoinInfoThumbprint
    }
}