DevOpsHandling/Get-ArtifactVersion.ps1

<#
 .Synopsis
  Gets info on an artifact for all versions
 .Description
  Returns info on an artifact for all versions from DevOps
 .Parameter devOpsOrganization
  Name of the organization in Azure DevOps
 .Parameter devOpsToken
  Personal access token for Azure DevOps
 .Parameter feed
  Feed to get the package from
 .Parameter packageName
  Package name to get the version from
 .Example
  $version = Get-ArtifactVersion -devOpsOrganization test -devOpsToken "" -packageName abc_app
#>

function Get-ArtifactVersion {
    Param (
        [Parameter(Mandatory=$true)]
        [string] $devOpsOrganization,
        [Parameter(Mandatory=$true)]
        [string] $devOpsToken,
        [Parameter(Mandatory=$true)]
        [string] $feed,
        [Parameter(Mandatory=$true)]
        [string] $packageName
    )

    try {
        $devOpsToken = Get-DevOpsToken -devOpsOrganization $devOpsOrganization -devOpsToken $devOpsToken

        (Invoke-AzureDevOpsApi -url ('https://feeds.dev.azure.com/{0}/_apis/packaging/feeds/{1}/Packages?packageNameQuery={2}' -f $devOpsOrganization, $feed, $packageName) -devOpsToken $devOpsToken).value[0]
    } catch {
        return ""
    }
}