-
Notifications
You must be signed in to change notification settings - Fork 2
/
Download-AzsMarkteplaceItem.ps1
40 lines (33 loc) · 1.21 KB
/
Download-AzsMarkteplaceItem.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<#
.SYNOPSIS
.DESCRIPTION
.EXAMPLE
#>
$ErrorActionPreference = "stop"
# check
Try {
Get-AzsLocation | Out-Null
} Catch {
Write-Error "Please login Azure Stack before you execute this script"
Break
}
$resourceGroupName = 'azurestack-activation'
$activation = Get-AzsAzureBridgeActivation -ResourceGroupName $resourceGroupName
Write-Output "Downloading list of marketplace items."
$list = Get-AzsAzureBridgeProduct -ActivationName $activation.Name -ResourceGroupName $resourceGroupName
$item = $list | Select-Object DisplayName,PublisherDisplayName,GalleryItemIdentity,PayloadLength,Id | Out-GridView -PassThru
if($item){
$downloadedItem = Get-AzsAzureBridgeDownloadedProduct -ActivationName $activation.Name -ResourceGroupName $resourceGroupName
# check
$downloadedItem | foreach {
if ( $_.GalleryItemIdentity -eq $item.GalleryItemIdentity ){
Write-Error "$($item.DisplayName) already downloaded"
exit
}
}
Write-Output "The following item will be downloaded. Please check marketplace after several hours."
$item
Invoke-AzsAzureBridgeProductDownload -ResourceId $item.Id -AsJob -Force | Out-Null
} else {
Write-Output "Please select item."
}