<#
.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.
.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 180 * 1024 * 1024 * 1024)
{
write-host -ForegroundColor red “[“(date -format “HH:mm:ss”)”]” ” — Check system disk failed – Size should be 180 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 120 * 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 96) {
write-host -ForegroundColor red “[“(date -format “HH:mm:ss”)”]” ” — Check system memory requirement failed. At least 96GB physical memory is required.”
$Global:ChecksFailure++
}
else
{
write-host -ForegroundColor green “[“(date -format “HH:mm:ss”)”]” ” — System memory check passed successfully. ASDK requires a minimum of 96 GB of RAM, with 128 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++
}
}