-
Notifications
You must be signed in to change notification settings - Fork 273
/
asdk-prechecker.ps1
388 lines (321 loc) · 19.3 KB
/
asdk-prechecker.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<#
.SYNOPSIS
Short description
This prechecker script validates the hardware and software requirements of your host to prepare for the deployment of the Azure Stack Development Kit
.DESCRIPTION
The script provides a way to confirm the host meets the hardware and software requirements, before downloading the larger package for the Azure Stack Development Kit.
For more information on ASDK requirements and considerations, see https://docs.microsoft.com/azure-stack/asdk/asdk-deploy-considerations.
.EXAMPLE
.\asdk-prechecker.ps1
.NOTES
To use this script on the host where Azure Stack Development Kit will be installed, you need to run it as an administrator (the script will check if it is running in this context).
You may also need to update the PowerShell script execution policy with Set-ExecutionPolicy, since the script is not signed : https://technet.microsoft.com/en-us/library/hh849812.aspx
The Azure Stack Development Kit Pre-Checker script is a PowerShell script published in this public repository so you can make improvements to it by submitting a pull request.
https://github.com/Azure/AzureStack-Tools
#>
#requires -runasadministrator
function CheckNestedVirtualization {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking for physical/virtual machine status..."
$BaseBoard = (Get-WmiObject Win32_BaseBoard)
If ($BaseBoard)
{
If (($BaseBoard.Manufacturer.Tolower() -match 'microsoft' -and $BaseBoard.Product.Tolower() -match 'virtual') -or ($BaseBoard.Manufacturer.Tolower() -match 'vmware'))
{
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- WARNING : This server seems to be a virtual machine running on Hyper-V or VMware. Running ASDK on a nested hypervisor is not a tested or supported scenario. Setup will not block this, but this but this may lead to performance or reliability issues."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- This is a physical machine."
$Global:ChecksSuccess++
}
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- This is a physical machine."
$Global:ChecksSuccess++
}
}
function CheckInternetAccess {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking Internet access..."
# Test AAD http connection.
try {
$resp = Invoke-WebRequest -Uri "https://login.windows.net" -UseBasicParsing
if ($resp.StatusCode -ne 200) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Failed to connect to AAD endpoint https://login.windows.net"
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- This machine has internet access (we tried to contact https://login.windows.net)."
$Global:ChecksSuccess++
}
}
catch {
write-host -ForegroundColor white "["(date -format "HH:mm:ss")"]" $_.Exception.Message
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Failed to connect to AAD endpoint 'https://login.windows.net'."
$Global:ChecksFailure++
}
}
function CheckSystemDisk {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking system disk capacity..."
$systemDisk = Get-Disk | ? {$_.IsSystem -eq $true}
If ($systemDisk.Size -lt 200 * 1024 * 1024 * 1024)
{
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Check system disk failed - Size should be 200 GB minimum."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- Check system disk passed successfully."
$Global:ChecksSuccess++
}
}
function CheckDisks {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking physical disks..."
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Listing of all physical disks on this server:"
write-host -ForegroundColor gray (Get-PhysicalDisk | Format-Table -Property @("FriendlyName", "SerialNumber", "CanPool", "BusType", "OperationalStatus", "HealthStatus", "Usage", "Size") | Out-String)
$physicalDisks = Get-PhysicalDisk | Where-Object { ($_.BusType -eq 'RAID' -or $_.BusType -eq 'SAS' -or $_.BusType -eq 'SATA') -and $_.Size -gt 135 * 1024 * 1024 * 1024 }
$selectedDisks = $physicalDisks | Group-Object -Property BusType | Sort-Object -Property Count -Descending | Select-Object -First 1
if ($selectedDisks.Count -ge 3) {
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Listing of all physical disks meeting ASDK requirements:"
write-host -ForegroundColor gray ($physicalDisks | Format-Table -Property @("FriendlyName", "SerialNumber", "BusType", "OperationalStatus", "HealthStatus", "Usage", "Size") | Out-String)
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- Check physical disks passed successfully. Note that ASDK handles situations where there is a pre-existing storage pool, and will delete/recreate it."
$Global:ChecksSuccess++
}
if ($selectedDisks.Count -lt 3) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Check physical disks failed - At least 4 disks or more of the same bus type (RAID/SAS/SATA), and of capacity 135 GB or higher are strongly recommended. 3-disk configurations may work but are not tested by Microsoft."
$Global:ChecksFailure++
}
}
function CheckFreeSpaceForExtraction {
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " Checking free space for extracting the ASDK files..."
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Listing disks and their free space"
write-host -ForegroundColor gray (Get-Disk | Get-Partition | Get-Volume | Sort-Object -Property SizeRemaining -Descending | Out-String)
$volumes = (Get-disk | ? {$_.BusType -ne 'File Backed Virtual' -or $_.IsBoot} | Get-Partition | Get-Volume |`
? {-not [String]::IsNullOrEmpty($_.DriveLetter)} | sort -Property SizeRemaining -Descending)
if (!$volumes -or ($volumes | Measure-Object).count -le 0) {
Write-Host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Free space check failed. No volumes are available."
$Global:ChecksFailure++
}
if ($volumes[0].SizeRemaining -lt 130 * 1024 * 1024 * 1024) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Free space check failed. ASDK requires 130 GB for the expanded Cloudbuilder.vhdx file. An additional 40 GB may be needed if you want to keep the ZIP and self extractor files."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- Free space check passed successfully."
$Global:ChecksSuccess++
}
}
function CheckRam {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking Memory..."
$mem = Get-WmiObject -Class Win32_ComputerSystem
$totalMemoryInGB = [Math]::Round($mem.TotalPhysicalMemory / (1024 * 1024 * 1024))
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Memory on this server = $totalMemoryInGB"
if ($totalMemoryInGB -lt 192) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Check system memory requirement failed. At least 192 GB physical memory is required (256 GB recommended)."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- System memory check passed successfully. ASDK requires a minimum of 192 GB of RAM, with 256 GB recommended."
$Global:ChecksSuccess++
}
}
function CheckHyperVSupport {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking Hyper-V support on the host..."
$feature = Get-WindowsFeature -Name "Hyper-V"
if ($feature.InstallState -ne "Installed") {
$cpu = Get-WmiObject -Class WIN32_PROCESSOR
$os = Get-WmiObject -Class Win32_OperatingSystem
if (($cpu.VirtualizationFirmwareEnabled -contains $false) -or ($cpu.SecondLevelAddressTranslationExtensions -contains $false) -or ($cpu.VMMonitorModeExtensions -contains $false) -or ($os.DataExecutionPrevention_Available -eq $false)) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Hyper-V is not supported on this host. Hardware virtualization is required for Hyper-V."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- This server supports the hardware virtualization required to enable Hyper-V."
$Global:ChecksSuccess++
}
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- Hyper-V is already installed. Note that the installer would enable it otherwise."
$Global:ChecksSuccess++
}
}
function CheckOSVersion {
# Check Host OS version first, otherwist DISM will failed to get VHD OS version
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking Host OS version..."
$hostOS = Get-WmiObject win32_operatingsystem
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" (" -- Host OS version: {0}, SKU: {1}" -f $hostOS.Version, $hostOS.OperatingSystemSKU)
$hostOSVersion = [Version]::Parse($hostOS.Version)
$server2016OSVersionRequired = "10.0.14393"
$server2016OSVersion = [Version]::Parse($server2016OSVersionRequired)
$serverDataCenterSku = 8 # Server Datacenter
$serverDataCenterEvalSku = 80 # Server Datacenter EVal
if ($hostOSVersion -lt $server2016OSVersion -or ($hostOS.OperatingSystemSKU -ne $serverDataCenterSku -and $hostOS.OperatingSystemSKU -ne $serverDataCenterEvalSku)) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- The host OS should be Windows Server 2016 Datacenter, version $server2016OSVersionRequired."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- The host OS version matches the requirements for ASDK ($server2016OSVersionRequired)."
$Global:ChecksSuccess++
}
}
function CheckDomainJoinStatus {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking domain join status..."
$sysInfo = Get-WmiObject -Class Win32_ComputerSystem
if ($sysInfo.PartOfDomain) {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- The host must not be domain joined. Please leave the domain and try again."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- The host is not domain joined."
$Global:ChecksSuccess++
}
}
function CheckVMSwitch {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking NIC status..."
if (([array](Get-NetAdapter | ? {$_.Status -eq 'Up'})).Count -ne 1) {
write-host -ForegroundColor darkyellow "["(date -format "HH:mm:ss")"]" " -- Multiple NICs, virtual switches or NIC teaming are not allowed. Please only keep one physical NIC enabled and remove virtual switches or NIC teaming. This message can be ignored if you are planning to leverage the ASDK Installer from GitHub, as it provides a way to configure the NICs."
$Global:ChecksSuccess++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- NIC configuration passed successfully."
$Global:ChecksSuccess++
}
}
function CheckServerName {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking server name..."
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Server name is" $Env:COMPUTERNAME
if ($Env:COMPUTERNAME -eq 'AzureStack') {
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- Server name cannot be ""AzureStack"" since it conflicts with the domain name."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- Server name does not conflict with future domain name AzureStack.local."
$Global:ChecksSuccess++
}
}
function CheckCPU {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking processor information..."
$CPUCount = (Get-WmiObject -class win32_processor -computername localhost).count
$CoreCount = ((Get-WmiObject -class win32_processor -computername localhost -Property "numberOfCores")[0].numberOfCores)*$CPUCount
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Number of CPU sockets = $CPUCount"
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" " -- Number of physical cores = $CoreCount"
If (($CPUCount -lt 2) -or ($CoreCount -lt 16)){
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- CPU count must be 2 or higher, Core count must be 16 or higher (20 cores recommended)."
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- CPU socket count ($CPUCount) and core count ($CoreCount) meet the minimum requirements for ASDK."
$Global:ChecksSuccess++
}
}
function CheckNICSupport {
write-host -ForegroundColor yellow "["(date -format "HH:mm:ss")"]" "Checking NIC requirements..."
$FoundNIC = $false
Get-NetAdapter -IncludeHidden | ForEach-Object {
$pnpDevoceId = $_.PnPDeviceID
if($pnpDevoceId -eq $null) { return }
$PnPDevice = Get-PnpDevice -InstanceId $pnpDevoceId
If ((Get-PnpDeviceProperty -InputObject $PnPDevice -KeyName DEVPKEY_Device_DriverInfPath).Data -eq "netbxnda.inf")
{
$FoundNIC = $true
}
}
If ($FoundNIC)
{
write-host -ForegroundColor darkyellow "["(date -format "HH:mm:ss")"]" " -- Please make sure to leverage the ASDK Installer for deployment, per the documentation. This installer will apply an update to this host prior to deployment."
$Global:ChecksSuccess++
}
else
{
write-host -ForegroundColor green "["(date -format "HH:mm:ss")"]" " -- Network cards requirements are met."
$Global:ChecksSuccess++
}
}
$ErrorActionPreference = 'Stop'
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "Starting Deployment Checker for Microsoft Azure Stack Development Kit (ASDK)..."
Write-Host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "There are several prerequisites checks to verify that your machine meets all the minimum requirements for deploying ASDK."
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "For more details, please refer to the online requirements : https://azure.microsoft.com/en-us/documentation/articles/azure-stack-deploy/"
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "Checking for Administrator priviledge..."
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator"))
{
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" " -- You do not have Administrator rights to run this script!`nPlease re-run this script as an Administrator!"
break
}
$checksHW = {CheckNestedVirtualization}, `
{CheckSystemDisk},
{CheckDisks},
{CheckRam}, `
{CheckCPU},
{CheckHyperVSupport}`
$CheckHWOnly = {CheckFreeSpaceForExtraction}
$checksSW = {CheckDomainJoinStatus}, `
{CheckInternetAccess}, `
{CheckOSVersion}, `
{CheckVMSwitch}, `
{CheckNICSupport},
{CheckServerName}
$Global:ChecksSuccess = 0
$Global:ChecksFailure = 0
#Checking if ASDK is already installed
$POCInstalledOrFailedPreviousInstall = $false
If ((get-module -Name Hyper-V -ListAvailable).count -gt 0)
{
$VMList = @("MAS-ACS01","MAS-ADFS01","MAS-ASql01","MAS-BGPNAT01","MAS-CA01","MAS-Con01","MAS-DC01","MAS-Gwy01","MAS-NC01", "MAS-SLB01", "MAS-SUS01", "MAS-WAS01", "MAS-Xrp01", "AzS-ACS01","AzS-ADFS01","AzS-ASql01","AzS-BGPNAT01","AzS-CA01","AzS-Con01","AzS-DC01","AzS-Gwy01","AzS-NC01", "AzS-SLB01", "AzS-SUS01", "AzS-WAS01", "AzS-Xrp01")
If ((Get-VM $VMList -ErrorAction SilentlyContinue).Count -gt 0)
{$POCInstalledOrFailedPreviousInstall = $true}
}
If ($POCInstalledOrFailedPreviousInstall)
{
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"] This machine seems to host an existing successful or failed installation of Azure Stack Development Kit. The prerequisite checker is meant to be run prior to installation, and will return errors post-install, as some of the configuration may already have been applied (joining the domain, setting up storage pools,...)"
If ((Read-Host "Do you want to continue anyway (Y/N)?") -eq "N")
{
break
}
}
write-host -ForegroundColor white "["(date -format "HH:mm:ss")"] This script can be run on the host where you will be configuring boot from VHD, for example prior to downloading the ASDK files. Or it can be run after booting from the provided Cloudbuilder.vhdx file where the ASDK will be installed. In the first case, it will only check for hardware specifications like memory, cores, hard disk configuration, as well as free space for extracting the ASDK files. In the second case, it will run both hardware and software tests, and other items like domain membership, OS version, NIC configuration will be checked."
Switch (Read-Host "Are you running this script on the host before booting in the provider VHDX file [1] or after booting into it [2] (any other input will exit the script)?")
{
"1"
{
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "User chose to run pre-boot from VHD checks (hardware checks only)"
$checks = $checksHW + $CheckHWOnly
}
"2"
{
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "User chose to run post-boot from VHD checks (all checks except free space)"
$checks = $checksHW + $checksSW
}
Default
{
write-host -ForegroundColor red "["(date -format "HH:mm:ss")"]" "User did not pick one of the two options, exiting script..."
exit
}
}
$PreCheckProgressMessage = "Running Prerequisites Check"
for($i=0; $i -lt $checks.Length; $i++)
{
Write-Progress -Activity $PreCheckProgressMessage -PercentComplete ($i * 100 / $checks.Length)
Invoke-Command -ScriptBlock $checks[$i] -NoNewScope
}
Write-Progress -Activity $PreCheckProgressMessage -Completed
If ($Global:ChecksSuccess -eq $Checks.Length)
{
Write-Host -ForegroundColor green "["(date -format "HH:mm:ss")"]" "SUCCESS : All of the prerequisite checks passed."
}
else
{
Write-Host -ForegroundColor red "["(date -format "HH:mm:ss")"]" "FAILURE:"$ChecksFailure "prerequisite check(s) failed out of" $Checks.Length ". Please review previous entries to understand where the requirements are not met."
}
write-host -ForegroundColor gray "["(date -format "HH:mm:ss")"]" "Deployment Checker has finished checking Azure Stack Development Kit requirements"