DevOpsHandling/Get-DevOpsArtifactsFromFeed.ps1

<#
 .Synopsis
  Retrieves artifact for a specific artifact from a feed
 .Description
  Retrieves artifact for a specific artifact name
 .Parameter devOpsOrganization
  The DevOps organization that contains the artifacts
  .Parameter devOpsFeed
  The name of the DevOps artifact feed
  .Parameter devOpsArtifact
  The artifact name to get - it will get the _app, _runtimeapp, and _tests apps
  .Parameter destination
  The output directory that the artifacts will be saved to
  .Parameter version
  The version of the artifact that should be retrieved. If not specified, it will be read from the settings.json
  .Example
  Get-DevOpsArtifactsFromFeed -devOpsArtifact "artifact" -devOpsFeed "feed" -devOpsArtifact "artifact" -destination "C:\Install" -version "1.0.0"
#>

function Get-DevOpsArtifactsFromFeed {
    Param(
        [Parameter(Mandatory = $true)]
        [string]$devOpsOrganization,
        [Parameter(Mandatory = $true)]
        [string]$devOpsFeed,
        [Parameter(Mandatory = $true)]
        [string]$devOpsArtifact,
        [Parameter(Mandatory = $true)]
        [string]$destination,
        [Parameter(Mandatory = $true)]
        [string]$version
    )

    $appsList = [System.Collections.ArrayList]@()

    $output = az artifacts universal download --organization ("https://dev.azure.com/" + $devOpsOrganization) --feed "$devOpsFeed" --name "$devOpsArtifact" --version "$version" --path "$destination"
    if (!$output) {
        throw "Could not download package $devOpsArtifact from $devOpsOrganization feed $devOpsFeed"
    }

    $files = (Get-ChildItem $destination -Filter "*.app")
    foreach ($file in $files) {
        if (!$file.Name.StartsWith('Microsoft')) {
            if (!$appsList.contains($file.FullName)) {
                [void]$appsList.Add($file.FullName)
            }
        }
    }

    return $appsList
}
Export-ModuleMember Get-DevOpsArtifactsFromFeed