internal/Find-LicenceSpdx.ps1

function Find-LicenceSpdx {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [String]
        $nugetFeedUrl,
        [Parameter(Mandatory = $true)]
        [xml]
        $combined
    )
    begin {
        $licences = Get-Licences

        $smoosh = @()
    }
    process {        
        foreach ($child in $combined.packages.ChildNodes) {
            try {
                Write-Information "looking for $($child.id)/$($child.version) on $nugetFeedUrl"
                $pack = Get-WebRequest "$nugetFeedUrl/search()?`$format=json&`$filter=id eq '$($child.id)' and version eq '$($child.version)'" | ConvertFrom-Json
            }
            catch {                
                Write-Information "error getting $($child.id)/$($child.version) from $nugetFeedUrl"
                Write-Error $_.Exception.Message
            }
        
            $licenceUrl = $($pack.d.results[0].LicenseUrl)
        
            Write-Information "$($child.id) $($child.version) : licenceUrl : $licenceUrl"
        
            if ($licenceUrl.Length -ne 0) {
                $match = $licences | Where-Object { $licenceUrl -like "*$($_.url)*" } | Select-Object -First 1
                Write-Information "$($child.id) $($child.version) : licenceUrl : $licenceUrl : $($match.licence)"
                $smoosh += @{"package" = "$($child.id)"; "version" = "$($child.version)"; "licenceUrl" = "$licenceUrl"; licenceType = "$($match.licence)"}
            }
            else {
                Write-Information "$($child.id) $($child.version) : licenceUrl : $licenceUrl : NO LICENCE"
                $smoosh += @{"package" = "$($child.id)"; "version" = "$($child.version)"; "licenceUrl" = ""; licenceType = "NO LICENCE"}
            } 
        }
    }
    end {
        $smoosh
    }
}