-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathAutoResize.ps1
More file actions
66 lines (61 loc) · 1.75 KB
/
AutoResize.ps1
File metadata and controls
66 lines (61 loc) · 1.75 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
57
58
59
60
61
62
63
64
<#Author : Dean Cefola
# Creation Date: 08-01-2022
# Usage : Auto Resize Script / Azure RunBook
#********************************************************************************
# Date Version Changes
#------------------------------------------------------------------------
# 08/01/2022 1.0 Intial Version
#
#*********************************************************************************
#
#>
##############################
# AutoResize Parameters #
##############################
Param (
[CmdletBinding()]
[Parameter(Mandatory=$true)]
[string]$LAWorkspaceName,
[Parameter(Mandatory=$true)]
[string]$Region,
[Parameter(Mandatory=$true)]
[string]$VMName,
[Parameter(Mandatory=$true)]
[string]$RGName
)
#$LAWorkspaceName = 'MSAA-LogAnalytics-r345xqot624z2'
##################
# Variables #
##################
$LAWorkspace = (Get-AzOperationalInsightsWorkspace `
| Where-Object `
-Property name `
-eq $LAWorkspaceName).CustomerId.GUID
###################
# Resize VMs #
###################
if($RGName -eq $null) {
Write-Host `
-ForegroundColor Cyan `
-BackgroundColor Black "Resize VM"
Wait-Event -Timeout 2
set-vmRightSize `
-targetVMName $VMName `
-workspaceId $LAWorkspace `
-region $Region `
-verbose `
-WhatIf
}
Else {
Write-Host `
-ForegroundColor yellow `
-BackgroundColor Black "Resize Resource Group"
Wait-Event -Timeout 2
set-rsgRightSize `
-targetRSG $RGName `
-workspaceId $LAWorkspace `
-region $Region ` `
-measurePeriodHours 24 `
-WhatIf `
-Verbose
}