-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDownload-and-Extract-MicrosoftAzureBackupServerv3.ps1
189 lines (135 loc) · 10.5 KB
/
Download-and-Extract-MicrosoftAzureBackupServerv3.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<#
.SYNOPSIS
A script used to download and extract Microsoft Azure Backup Server v3 for a new deployment.
.DESCRIPTION
A script used to download Microsoft Azure Backup Server v3 for a new deployment. All required files, the .exe and seven .bin files will be downloaded in the C:\Temp folder. The C:\Temp folder will be created if it not already exists.
After the download, the .exe file will run, which extracts all .bin files to the Microsoft Azure Backup Server folder underneath C:\Temp. When extraction is completed all .bin and the .exe file will be cleaned up.
After which Setup.exe will run, which opens the Microsoft Azure Backup Server splash screen to start a manual installation.
the download the seven compressed .bin files will be extracted and setup.exe will be started.
Which will open the installation splash screen, from where Microsoft Azure Backup Server can be installed.
.NOTES
Filename: Download-and-Extract-MicrosoftAzureBackupServerv3.ps1
Created: 19/08/2021
Last modified: 19/08/2021
Author: Wim Matthyssen
PowerShell: Windows PowerShell, PowerShell Core
Version: Minimum v 5.1
Windows Server: Windows Server 2019, Windows Server 2016
Action: Change variables were needed to fit your needs.
Disclaimer: This script is provided "As IS" with no warranties.
.EXAMPLE
Download-and-Extract-MicrosoftAzureBackupServerv3.ps1
.LINK
https://wmatthyssen.com/2020/08/01/azure-powershell-script-create-a-management-group-tree-hierarchy/
#>
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Variables
$tempFolder = "C:\Temp\"
$itemType = "Directory"
$mabsUrl1 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller.exe"
$mabsUrl2 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-1.bin"
$mabsUrl3 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-2.bin"
$mabsUrl4 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-3.bin"
$mabsUrl5 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-4.bin"
$mabsUrl6 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-5.bin"
$mabsUrl7 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-6.bin"
$mabsUrl8 = "https://download.microsoft.com/download/C/9/3/C93CABA5-2776-4417-8DB2-20B85E6EBA3B/MicrosoftAzureBackupServerInstaller-7.bin"
$mabsExtFile1 = "C:\Temp\MicrosoftAzureBackupInstaller.exe"
$mabsExtFile2 = "C:\Temp\MicrosoftAzureBackupInstaller-1.bin"
$mabsExtFile3 = "C:\Temp\MicrosoftAzureBackupInstaller-2.bin"
$mabsExtFile4 = "C:\Temp\MicrosoftAzureBackupInstaller-3.bin"
$mabsExtFile5 = "C:\Temp\MicrosoftAzureBackupInstaller-4.bin"
$mabsExtFile6 = "C:\Temp\MicrosoftAzureBackupInstaller-5.bin"
$mabsExtFile7 = "C:\Temp\MicrosoftAzureBackupInstaller-6.bin"
$mabsExtFile8 = "C:\Temp\MicrosoftAzureBackupInstaller-7.bin"
$extFolderName = "C:\Microsoft Azure Backup Server"
$global:currenttime= Set-PSBreakpoint -Variable currenttime -Mode Read -Action {$global:currenttime= Get-Date -UFormat "%A %m/%d/%Y %R"}
$foregroundColor1 = "Red"
$foregroundColor2 = "Yellow"
$writeEmptyLine = "`n"
$writeSeperatorSpaces = " - "
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Check if running as Administrator, otherwise close the PowerShell window
$CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$IsAdministrator = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ($IsAdministrator -eq $false) {
Write-Host ($writeEmptyLine + "# Please run PowerShell as Administrator" + $writeSeperator + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
Start-Sleep -s 5
exit
}
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Download started
Write-Host ($writeEmptyLine + "# MABS v3 download started" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Create a Temp folder on C: if it not exists
If (!(Test-Path -Path $tempFolder)){New-Item -ItemType $itemType -Force -Path $tempFolder
Write-Host ($writeEmptyLine + "# Temp folder created" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
}Else {Write-Host ($writeEmptyLine + "# Temp folder already exists" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine}
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Download MABS v3 software and save to C:\Temp
Import-Module BitsTransfer
Start-BitsTransfer -Source $mabsUrl1 -Destination $mabsExtFile1
for ($i = 1; $i -lt 2; $i++) {write-host}
Write-Host ($writeEmptyLine + "# Download .exe completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl2 -Destination $mabsExtFile2
Write-Host ($writeEmptyLine + "# Download .bin part 1/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl3 -Destination $mabsExtFile3
Write-Host ($writeEmptyLine + "# Download .bin part 2/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl4 -Destination $mabsExtFile4
Write-Host ($writeEmptyLine + "# Download .bin part 3/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl5 -Destination $mabsExtFile5
Write-Host ($writeEmptyLine + "# Download .bin part 4/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl6 -Destination $mabsExtFile6
Write-Host ($writeEmptyLine + "# Download .bin part 5/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl7 -Destination $mabsExtFile7
Write-Host ($writeEmptyLine + "# Download .bin part 6/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
Start-BitsTransfer -Source $mabsUrl8 -Destination $mabsExtFile8
Write-Host ($writeEmptyLine + "# Download .bin part 7/7 completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine
for ($i = 1; $i -lt 2; $i++) {write-host}
Write-Host ($writeEmptyLine + "# Download completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Extraction started
Write-Host ($writeEmptyLine + "# Starting extraction" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Run MicrosoftAzureBackupInstaller.exe
Start-Process $mabsExtFile1 /SILENT -Wait
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Move extracted folder
Move-Item $extFolderName $tempFolder
for ($i = 1; $i -lt 2; $i++) {write-host}
Write-Host ($writeEmptyLine + "# Extraction completed" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Clean up extracted files
[System.Collections.ArrayList]$mabsexfiles = $mabsExtFile1, $mabsExtFile2, $mabsExtFile3, $mabsExtFile4, $mabsExtFile5, $mabsExtFile6, $mabsExtFile7, $mabsExtFile8
Remove-Item $mabsexfiles
for ($i = 1; $i -lt 2; $i++) {write-host}
Write-Host ($writeEmptyLine + "# Cleaned up extracted files" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Run Microsoft Azure Backup Server setup
& "C:\Temp\Microsoft Azure Backup Server\Setup.exe"
for ($i = 1; $i -lt 2; $i++) {write-host}
Write-Host ($writeEmptyLine + "# MABS v3 setup started" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
## Exit PowerShell window 3 seconds after completion
Write-Host ($writeEmptyLine + "# Script completed, the PowerShell window will close in 3 seconds" + $writeSeperatorSpaces + $currentTime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine
Start-Sleep 3
stop-process -Id $PID
## ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------