-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRemove-AzureDtlRGDeployment.ps1
54 lines (38 loc) · 1.29 KB
/
Remove-AzureDtlRGDeployment.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
[cmdletbinding()]
param
(
[Parameter(Mandatory = $true, HelpMessage = "Name of Lab")]
[string] $LabName
)
trap {
# NOTE: This trap will handle all errors. There should be no need to use a catch below in this
# script, unless you want to ignore a specific error.
Handle-LastError
}
try {
. .\Common.ps1
$credentialsKind = InferCredentials
if ($credentialsKind -eq "Runbook") {
$TemplatePath = Get-AutomationVariable -Name 'TemplatePath'
}
else {
$path = Resolve-Path $TemplatePath
$templateContent = [IO.File]::ReadAllText($path)
}
if ($BatchSize -gt 100) {
throw "BatchSize must be less or equal to 100"
}
LogOutput "Start management ..."
LoadAzureCredentials -credentialsKind $credentialsKind -profilePath $profilePath
$credentialsKind = InferCredentials
$ResourceGroupName = GetResourceGroupName -labname $LabName
$deploymentGroup = Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName
$deploymentGroup.count
Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName | Remove-AzureRmResourceGroupDeployment -Verbose -Force
}
finally {
if ($credentialsKind -eq "File") {
1..3 | % { [console]::beep(2500, 300) } # Make a sound to indicate we're done if running from command line.
}
popd
}