forked from jagilber/powershellScripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-rm-check-vm-config-schema.ps1
80 lines (66 loc) · 2.15 KB
/
azure-rm-check-vm-config-schema.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
param(
[string]$location = "eastus",
[string]$vmSize = "Basic_A1",
[string]$publisher = "MicrosoftWindowsServer", #"Canonical"
[string]$offer = "WindowsServer", #"UbuntuServer"
[string]$imagesku = "2016-Datacenter-with-containers", #"18.04-LTS"
[switch]$showDetail
)
write-host "checking location $($location)"
$locations = Get-AzureRmLocation
if (!($locations | Where-Object Location -Like $location) -or !$location)
{
$locations.Location
write-warning "location: $($location) not found. supply -location using one of the above locations and restart script."
return
}
if($showDetail)
{
$locations.location
}
write-host "checking publisher $($publisher)"
$publishers = Get-AzureRmVMImagePublisher -Location $location
if(!($publishers| Where-Object PublisherName -Match $publisher))
{
$publishers
write-warning "publisher: $($publisher) not found. supply -location using one of the above locations and restart script."
return
}
$publisherName = ($publishers| Where-Object PublisherName -Match $publisher)[0].PublisherName
if($showDetail)
{
$publishers | fl *
}
write-host "checking vm size $($vmSize) in $($location)"
$vmSizes = Get-AzureRmVMSize -Location $location
if (!($vmSizes | Where-Object Name -Like $vmSize))
{
$vmSizes
write-warning "vmSize: $($vmSize) not found in $($location). correct -vmSize using one of the above options and restart script."
return
}
if($showDetail)
{
$vmSizes | fl *
}
write-host "checking sku $($publisherName) $($offer) $($imageSku)"
$skus = Get-AzureRmVMImageSku -Location $location -PublisherName $publisherName -Offer $offer
if (!($skus | Where-Object Skus -Like $imageSKU))
{
$skus
write-warning "image sku: $($imageSku) not found in $($location). correct -imageSKU using one of the above options and restart script."
return
}
if($showDetail)
{
$skus | fl *
}
if($showDetail)
{
foreach($sku in $skus)
{
write-host "checking sku image $($publisherName) $($offer) $($imageSku) $($sku.skus)"
$imageskus = Get-AzureRmVMImage -Location $location -PublisherName $publisherName -Offer $offer -skus $sku.skus
$imageskus | fl *
}
}