Skip to content

Instantly share code, notes, and snippets.

@ned1313
Last active January 10, 2019 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ned1313/e6d8501a7181b8bfaa34e954f01dea86 to your computer and use it in GitHub Desktop.
Save ned1313/e6d8501a7181b8bfaa34e954f01dea86 to your computer and use it in GitHub Desktop.
Helper Scripts for setting up the Azure Stack Development Kit
<#
This script is meant to make downloading the latest ASDK a simple affair. The files that
make up the ASDK are an executable and several bin files. This script will grab the
latest version of the ASDK from the web and then assemble the bin files into the final VHDX.
Make sure you have 40GB of free space on your C drive, or change the destination!
This does not include the process of installing the ASDK. That's a whole separate thing.
#>
#Set up the path and source URI
$asdkDownloadPath = "C:\ASDKFiles"
$asdkExtractFolder = "ExtractedFiles"
$asdkURIDownloads = "https://aka.ms/azurestack-asdkdownloads"
#Get the release info
$resp = Invoke-RestMethod -Method Get https://aka.ms/azurestack-asdkdownloads
$resp2 = Invoke-RestMethod -Method Get -Uri $resp.DownloadProduct.DownloadReleases.Uri
#Get the list of files and create a destination path for each
$downloadList = $resp2.DownloadFileList.Files.FileName
$AsdkFiles = @()
foreach ($AsdkFile in $downloadList)
{
$AsdkFiles += Join-Path -Path $asdkDownloadPath -ChildPath $AsdkFile
}
#Use BITS to download the files, these are BIG
$downloadList | ForEach-Object {Start-BitsTransfer -Source "$($resp2.DownloadFileList.DownloadSource)$_" -DisplayName $_ -Destination $asdkDownloadPath -Asynchronous}
#This while loop will run until all the BITS transfers are complete, that might be a while
#Maybe go get lunch or call your mother. She likes that sort of thing.
while(Get-BitsTransfer){Get-BitsTransfer | ?{$_.JobState -eq "Transferred"} | Complete-BitsTransfer}
#Now we extract the VHDX from all those bin files
$f = $AsdkFiles | Where-Object {$_ -like "*.exe"}
$o = Join-Path -Path $asdkDownloadPath -ChildPath $asdkExtractFolder
Start-Process -FilePath $f -ArgumentList "/dir=`"$o`"", "/SILENT", "/NOCANCEL" -Wait
#Now that you have the full VHDX, go get the asdk-installer script
$Uri = 'https://raw.githubusercontent.com/Azure/AzureStack-Tools/master/Deployment/asdk-installer.ps1'
$LocalPath = 'C:\AzureStack_Installer'
# Create folder
New-Item $LocalPath -Type directory
# Enforce usage of TLSv1.2 to download from GitHub
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Download file
Invoke-WebRequest $uri -OutFile ($LocalPath + '\' + 'asdk-installer.ps1')
<#
This script is meant to download and run the ConfigASDK script created by Matt McSpirit.
You can check that out here: https://github.com/mattmcspirit/azurestack/tree/master/deployment
This will install EVERYTHING. That includes the MySQL, SQL, and AppService RPs. You will need
to download the Server 2016 ISO ahead of time as well. That
#>
#Create the destination for files
New-Item -ItemType Directory -Force -Path “D:\ConfigASDK”
New-Item -ItemType Directory -Force -Path “D:\ASDKFiles”
Set-Location “D:\ConfigASDK”
#Get Server 2016 ISO
Start-BitsTransfer -Source https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO -Destination D:\ConfigASDK\Windows_Server_2016_Datacenter.ISO
#Get the latest version of the script
Invoke-Webrequest http://bit.ly/configasdk -UseBasicParsing -OutFile ConfigASDK.ps1
#Update the variables with the correct value
$azureDirectoryTenantName = "XXX.onmicrosoft.com"
$azureAdUsername = "admin@XXX.onmicrosoft.com"
$azureAdPassword = 'password for the Azure AD User'
$azueRedSubId = "YOUR-SUB-ID-HERE"
$ISOPath = "D:\ConfigASDK\Windows_Server_2016_Datacenter.ISO"
$password = 'Password to use for all the VMs'
#Run the ConfigASDK and go out for lunch, dinner, and probably dessert. You've earned it!
.\ConfigASDK.ps1 -azureDirectoryTenantName $azureDirectoryTenantName -authenticationType AzureAD `
-downloadPath "D:\ASDKfiles" -ISOPath $ISOPath -azureStackAdminPwd $password -VMpwd $password `
-azureAdUsername $azureAdUsername -azureAdPwd $azureAdPassword -registerASDK -useAzureCredsForRegistration `
-azureRegSubId $azueRedSubId
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment