-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployment-check.ps1
100 lines (85 loc) · 3.22 KB
/
deployment-check.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<#
.SYNOPSIS
This script checks the deployment status of private clouds and monitors the provisioning process.
.DESCRIPTION
The script prompts the user to monitor a deployment or skip the deployment check. If the user chooses to monitor, it retrieves a list of private clouds and allows the user to select a private cloud to check the deployment status. It then continuously checks the provisioning status of the selected private cloud until it is no longer in the "Building" state.
.PARAMETER None
.INPUTS
None
.OUTPUTS
None
.EXAMPLE
.\deployment-check.ps1
Prompts the user to monitor a deployment and select a private cloud to check the deployment status.
.NOTES
Author: Fletcher Kelly
Date: 22-11-2023
#>
#deployment check
## Do yo have AVS Module installed?
if (Get-Module -ListAvailable -Name Az.VMware)
{ write-output "Module exists"
} else {
write-output "Module does not exist"
write-output "Installing Module"
Install-Module -Name Az.VMware
}
Write-Output "Waiting 60 seconds before checking deployment status"
Start-Sleep -s 60
$YesOrNo = Read-Host "Do you need to monitor a deployment (y/n)"
while("y","n" -notcontains $YesOrNo ) {
$YesOrNo = Read-Host "Please enter your response (y/n)"
}
if ($YesOrNo -eq "y") {
Write-Output "Monitoring deployment"
} else {
Write-Output "Skipping deployment check"
break
}
$privateClouds = Get-AzVMwarePrivateCloud
[int]$privateCloudCount = $privateClouds.count
Write-output "Found $privateCloudCount private clouds"
$i = 0
foreach ($privateCloud in $privateClouds)
{
$cloudValue = $i
$cloudText = [string]$cloudValue + " : " + $privateCloud.Name + " ( " + $privateCloud.ResourceGroupName + " )" + ":" + $privateCloud.Location
Write-output $cloudText
$i++
}
Do
{
[int]$privateCloudChoice = read-host -prompt "Select a private to check deployment & press enter"
}
until ($privateCloudChoice -le $privateCloudCount)
$selectedprivateCloud = "You selected " + $privateClouds[$privateCloudChoice].Name
Write-output $selectedprivateCloud
$privateCloudRgName = $privateClouds[$privateCloudChoice].resourcegroupname
$privateCloudLocation = $privateClouds[$privateCloudChoice].location
$cloudName = $privateClouds[$privateCloudChoice].name
$privateCloud = Get-AzVMwarePrivateCloud -ResourceGroupName $privateCloudRgName -Name $cloudName
do {
$privateCloud = Get-AzVMwarePrivateCloud -ResourceGroupName $privateCloudRgName -Name $cloudName
$provisioningStatus = $privateCloud.provisioningState
$timestamp = get-date -Format "dd-MM-yyyy - HH:mm:ss"
switch ($provisioningStatus) {
"Building"
{
$statusMessage = "Provisioning status for $cloudName is : " + $provisioningStatus + " ($timestamp)"
Write-Output $statusMessage
Start-Sleep -Seconds 300
}
"Succeeded"
{
$statusMessage = "Provisioning status for $cloudName is : " + $provisioningStatus + " ($timestamp)"
Write-Output $statusMessage
break
}
Default
{
Start-Sleep -Seconds 300
$statusMessage = "Provisioning status for $cloudName is : " + $provisioningStatus + " ($timestamp)"
Write-Output $statusMessage
}
}
} until ($provisioningStatus -ne "Building" )