-
Notifications
You must be signed in to change notification settings - Fork 9
/
Manage.ps1
35 lines (30 loc) · 875 Bytes
/
Manage.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
[CmdletBinding()]
Param(
[string]$ResourceGroup,
[string]$ScaleSet = "ScaleSet",
[Parameter(Mandatory=$true)]
$Action
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
Get-AzureRmResourceGroup -Name $ResourceGroup -ErrorVariable notPresent -ErrorAction SilentlyContinue | Out-Null
if ( $notPresent) {
"Resource group $ResourceGroup does not exist. Exiting script"
exit
}
try {
Get-AzureRmVmss -ResourceGroupName $ResourceGroup -VMScaleSetName $ScaleSet | Out-Null
}
catch {
"Scale set $ScaleSet does not exist. Exiting script"
exit
}
If ($Action -eq "Start") {
Start-AzureRmVmss -ResourceGroupName $ResourceGroup -VMScaleSetName $ScaleSet
}
ElseIf ($Action -eq "Stop") {
Stop-AzureRmVmss -ResourceGroupName $ResourceGroup -VMScaleSetName $ScaleSet -Force
}
Else {
Write-Error "Unregonized action $Action"
}