-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeploySharedImageGallery.ps1
More file actions
58 lines (43 loc) · 1.82 KB
/
DeploySharedImageGallery.ps1
File metadata and controls
58 lines (43 loc) · 1.82 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$RGName = 'acme-dev-eus-sig-rg'
$Location = 'EastUs'
New-AzResourceGroup `
-Name $RGName `
-Location $Location
$resourceGroup = Get-AzResourceGroup -Name $RGName
$GalleryName ='acmedevsig'
New-AzGallery `
-GalleryName $GalleryName `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-Location $resourceGroup.Location `
-Description 'Shared Image Gallery for my organization'
$gallery = Get-AzGallery -Name $GalleryName
$GallaryImageName = 'windows-server-2019-base'
New-AzGalleryImageDefinition `
-GalleryName $gallery.Name `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-Location $gallery.Location `
-Name $GallaryImageName `
-OsState generalized `
-OsType Windows `
-Publisher 'acme' `
-Offer 'baseoffer' `
-Sku 'windowsserver2019'
$galleryImage = Get-AzGalleryImageDefinition -Name $GallaryImageName -ResourceGroupName $resourceGroup.ResourceGroupName -GalleryName $gallery.Name
#$region1 = @{Name='EastUs2';ReplicaCount=1}
$region2 = @{Name='EastUs';ReplicaCount=1}
#$targetRegions = @($region1,$region2)
$targetRegions = @($region2)
$GalleryImageVersionName = '1.0.1'
$managedImage = Get-AzImage `
-ImageName "windows-server-2019-base" `
-ResourceGroupName "acme-dev-eus-sigt-01-rg"
New-AzGalleryImageVersion `
-GalleryImageDefinitionName $galleryImage.Name `
-GalleryImageVersionName $GalleryImageVersionName `
-GalleryName $gallery.Name `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-Location $resourceGroup.Location `
-TargetRegion $targetRegions `
-Source $managedImage.Id.ToString() `
-PublishingProfileEndOfLifeDate '2030-01-01' `
$imageVersion = get-azGalleryImageVersion -Name $GalleryImageVersionName -ResourceGroupName $resourceGroup.ResourceGroupName -GalleryName $gallery.Name -GalleryImageDefinitionName $galleryImage.Name