Skip to content

Commit

Permalink
Merge pull request #435 from microsoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Jaromir Kaspar authored Apr 5, 2021
2 parents 733fc36 + dac7644 commit affde4e
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 76 deletions.
11 changes: 5 additions & 6 deletions Scenarios/AzSHCI and Kubernetes/Scenario.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ Invoke-Command -ComputerName $ClusterName -ScriptBlock {
#endregion

#region Download AKS HCI module
Start-BitsTransfer -Source "https://aka.ms/aks-hci-download" -Destination "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Feb-2021.zip"
Start-BitsTransfer -Source "https://aka.ms/aks-hci-download" -Destination "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Mar-2021.zip"
#unzip
Expand-Archive -Path "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Feb-2021.zip" -DestinationPath "$env:USERPROFILE\Downloads" -Force
Expand-Archive -Path "$env:USERPROFILE\Downloads\AKS-HCI-Public-Preview-Mar-2021.zip" -DestinationPath "$env:USERPROFILE\Downloads" -Force
Expand-Archive -Path "$env:USERPROFILE\Downloads\AksHci.Powershell.zip" -DestinationPath "$env:USERPROFILE\Downloads\AksHci.Powershell" -Force

#endregion
Expand Down Expand Up @@ -248,18 +248,17 @@ Expand-Archive -Path "$env:USERPROFILE\Downloads\AksHci.Powershell.zip" -Destina
#configure aks
Invoke-Command -ComputerName $servers[0] -Credential $Credentials -Authentication Credssp -ScriptBlock {
$vnet = New-AksHciNetworkSetting -vnetName $using:vSwitchName -vippoolstart $using:vippoolstart -vippoolend $using:vippoolend
Set-AksHciConfig -vnet $vnet -workingDir c:\clusterstorage\$using:VolumeName\Images -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" -enableDiagnosticData -controlPlaneVmSize = 'default' # Get-AksHciVmSize
#Set-AksHciConfig -vnet $vnet -workingDir c:\clusterstorage\$using:VolumeName\Images -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" -enableDiagnosticData -controlPlaneVmSize = 'default' # Get-AksHciVmSize
Set-AksHciConfig -vnet $vnet -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS" -enableDiagnosticData -controlPlaneVmSize = 'default' # Get-AksHciVmSize
}

#validate config
Invoke-Command -ComputerName $servers[0] -ScriptBlock {
Get-AksHciConfig
}

#note: this step might need to run twice. As for first time it times out on https://github.com/Azure/aks-hci/issues/28 . Before second attempt, unistall-akshci first and set config again
#Install
Invoke-Command -ComputerName $servers[0] -Credential $Credentials -Authentication Credssp -ScriptBlock {
#Uninstall-AksHCI
#Set-AksHciConfig -vnetName $using:vSwitchName -workingDir c:\clusterstorage\$using:VolumeName\Images -imageDir c:\clusterstorage\$using:VolumeName\Images -cloudConfigLocation c:\clusterstorage\$using:VolumeName\Config -ClusterRoleName "$($using:ClusterName)_AKS"
Install-AksHci
}

Expand Down
8 changes: 4 additions & 4 deletions Scenarios/Azure Image Builder/Scenario.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
#location
$location="westeurope"
# ImageDefinitionName
$imageDefName ="Windows10_20H2_WVD"
$imageDefName ="Win10_20H2_WVD"
#Subscription ID
$subscriptionID = (Get-AzContext).Subscription.Id
# Create the gallery
Expand Down Expand Up @@ -134,7 +134,7 @@
#name of Identity for Azure Image Builder Service
$identityName="AzureImageBuilderService"
# ImageDefinitionName
$imageDefName ="Windows10_20H2_WVD"
$imageDefName ="Win10_20H2_WVD"
#Image gallery name
$sigGalleryName= "AzureImageBuilderSharedGallery"
#grab identity
Expand All @@ -144,8 +144,8 @@
# Azure replication region
$replocation = 'northeurope'
# Name of the image to be created
$date=get-date -Format "dd-MM-yy"
$imageTemplateName = "Windows10_20H2_WVD_$date"
$date=get-date -Format "yyMMdd"
$imageTemplateName = "Win10_20H2_WVD_$date"
# Distribution properties of the managed image upon completion
$runOutputName = 'myDistResults'
# Grab Subscription ID
Expand Down
2 changes: 1 addition & 1 deletion Scenarios/Azure Image Builder/armTemplateWVD.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

"vmProfile":
{
"vmSize": "Standard_D2_v2",
"vmSize": "Standard_D2s_v4",
"osDiskSizeGB": 127
},

Expand Down
23 changes: 10 additions & 13 deletions Scripts/3_Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ If (-not $isAdmin) {
$RunSynchronous
)

if ( Test-Path "Unattend.xml" ) {
Remove-Item .\Unattend.xml
if ( Test-Path "$PSScriptRoot\Temp\unattend.xml" ) {
Remove-Item "$PSScriptRoot\Temp\unattend.xml"
}
$unattendFile = New-Item "Unattend.xml" -type File
$unattendFile = New-Item "$PSScriptRoot\Temp\unattend.xml" -type File
$fileContent = @"
<?xml version='1.0' encoding='utf-8'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Expand Down Expand Up @@ -105,10 +105,10 @@ If (-not $isAdmin) {
$AdditionalAccount
)

if ( Test-Path "Unattend.xml" ) {
Remove-Item .\Unattend.xml
if ( Test-Path "$PSScriptRoot\Temp\unattend.xml" ) {
Remove-Item "$PSScriptRoot\Temp\unattend.xml"
}
$unattendFile = New-Item "Unattend.xml" -type File
$unattendFile = New-Item "$PSScriptRoot\Temp\unattend.xml" -type File
$fileContent = @"
<?xml version='1.0' encoding='utf-8'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Expand Down Expand Up @@ -170,10 +170,10 @@ If (-not $isAdmin) {
[string]
$DomainName
)
if ( Test-Path "Unattend.xml" ) {
Remove-Item .\Unattend.xml
if ( Test-Path "$PSScriptRoot\Temp\unattend.xml" ) {
Remove-Item "$PSScriptRoot\Temp\unattend.xml"
}
$unattendFile = New-Item "Unattend.xml" -type File
$unattendFile = New-Item "$PSScriptRoot\Temp\unattend.xml" -type File
$fileContent = @"
<?xml version='1.0' encoding='utf-8'?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Expand Down Expand Up @@ -1518,11 +1518,8 @@ If (-not $isAdmin) {

#a bit cleanup
Remove-Item -Path "$PSScriptRoot\temp" -Force -Recurse
if (Test-Path "$PSScriptRoot\unattend.xml") {
remove-item "$PSScriptRoot\unattend.xml"
}

#set MacSpoofing and AllowTeaming (for SET switch in VMs to work properly with vNICs)
#set MacSpoofing and AllowTeaming (for SET switch in VMs to work properly with vNICs)
WriteInfo "`t Setting MacSpoofing On and AllowTeaming On"
Set-VMNetworkAdapter -VMName "$($labconfig.Prefix)*" -MacAddressSpoofing On -AllowTeaming On

Expand Down
94 changes: 42 additions & 52 deletions Tools/DownloadLatestCUs.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
If ((Get-ExecutionPolicy) -ne "RemoteSigned"){
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
$Products=@()
$Products+=@{Product="Azure Stack HCI 20H2";SearchString="Cumulative Update for Azure Stack HCI, version 20H2" ;SSUSearchString="Servicing Stack Update for Azure Stack HCI, version 20H2 for x64-based Systems"}
$Products+=@{Product="Windows Server 2019" ;SearchString="Cumulative Update for Windows Server 2019 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2019 for x64-based Systemss"}
$Products+=@{Product="Windows Server 2016" ;SearchString="Cumulative Update for Windows Server 2016 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows Server 2016 for x64-based Systemss"}
$Products+=@{Product="Windows 10 20H2" ;SearchString="Cumulative Update for Windows 10 Version 20H2 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 20H2 for x64-based Systems"}
$Products+=@{Product="Windows 10 2004" ;SearchString="Cumulative Update for Windows 10 Version 2004 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 2004 for x64-based Systems"}
$Products+=@{Product="Windows 10 1909" ;SearchString="Cumulative Update for Windows 10 Version 1909 for x64-based Systems";SSUSearchString="Servicing Stack Update for Windows 10 Version 1909 for x64-based Systems"}

#grab folder to download to
$folder=Read-Host -Prompt "Please type path to download. For example `"c:\temp`" (if nothing specified, $PSScriptRoot is used)"
if(!$folder){$folder=$PSScriptRoot}

#do you want preview?
$preview=Read-Host -Prompt "Do you want to download preview updates? Y/N, default N"
if($preview -eq "y"){
$preview = $true
}else{
$preview=$false
}

#set TLS 1.2 for github downloads
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
#let user choose products
$SelectedProducts=$Products.Product | Out-GridView -OutputMode Multiple -Title "Please select products to download Cumulative Updates and Servicing Stack Updates"

#download LatestUpdate module
Write-Output "Checking if LatestUpdate PS Module is Installed"
if (!(Get-InstalledModule -Name LatestUpdate -ErrorAction Ignore)){
#region download MSCatalog module
Write-Output "Checking if MSCatalog PS Module is Installed"
if (!(Get-InstalledModule -Name MSCatalog -ErrorAction Ignore)){
# Verify Running as Admin
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
If (!( $isAdmin )) {
Expand All @@ -16,57 +32,31 @@ if (!(Get-InstalledModule -Name LatestUpdate -ErrorAction Ignore)){
exit
}
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name LatestUpdate -Force
}

#check if latest json is added
$jsonweb=(Invoke-WebRequest -UseBasicParsing -Uri https://raw.githubusercontent.com/aaronparker/LatestUpdate/master/LatestUpdate/LatestUpdate.json).content | ConvertFrom-Json
$jsonlocal=Get-Content -Path "$((Get-InstalledModule -Name LatestUpdate).InstalledLocation)\LatestUpdate.json" | ConvertFrom-Json
if (($jsonlocal.ParameterValues.Windows10Versions).Count -ne ($jsonweb.ParameterValues.Windows10Versions).Count){
Write-Output "JSON on Local web is different, replacing local JSON"
#elevate process
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
If (!( $isAdmin )) {
Write-Host "-- Restarting as Administrator to replace JSON in LatestUpdate Module" -ForegroundColor Cyan ; Sleep -Seconds 1
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
}
$jsonweb | ConvertTo-Json | Out-File "$((Get-InstalledModule -Name LatestUpdate).InstalledLocation)\LatestUpdate.json"
If ((Get-ExecutionPolicy) -ne "RemoteSigned"){
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
}
Install-Module -Name MSCatalog -Force
}

#grab folder to download to
$folder=Read-Host -Prompt "Please type path to download. For example `"c:\temp`" (if nothing specified, $PSScriptRoot is used)"
if(!$folder){$folder=$PSScriptRoot}

#grab versions to download
$versions=$jsonweb.ParameterValues.Windows10Versions | Out-GridView -OutputMode Multiple -Title "Select versions to download"

foreach ($Version in $versions){
Write-Output "Fetching for latest CU info from web"
$latestCU=Get-LatestCumulativeUpdate -OperatingSystem Windows10 -Version $Version | Where-Object -Property Note -Like "*Windows 10*x64*" | Select-Object -First 1 #1903 has 2 objects
$CUFilename=$latestCU.URL.Split('/') | Select-Object -Last 1
$path="$folder\$version\$($latestCU.Note.Substring(0,7))"
New-Item -Path $path -ItemType Directory -ErrorAction Ignore | Out-Null
if (Test-Path -Path "$path\$CUFilename"){
Write-Output "$CUFilename already present. Skipping download"
}else{
Write-Output "Downloading $CUFilename"
$latestCU | Save-LatestUpdate -Path $path
}
#endregion

Write-Output "Fetching for latest SSU info from web"
$latestSSU=Get-LatestServicingStackUpdate -OperatingSystem Windows10 -Version $Version | Where-Object -Property Note -Like "*Windows 10*x64*"
$SSUFilename=$latestSSU.URL.Split('/') | Select-Object -Last 1
if (Test-Path -Path "$path\$SSUFilename"){
Write-Output "$SSUFilename already present. Skipping download"
#region download products
Foreach($SelectedProduct in $SelectedProducts){
$item=$Products | Where-Object product -eq $SelectedProduct
#Download CU
If ($preview){
$update=Get-MSCatalogUpdate -Search $item.searchstring | Select-Object -First 1
}else{
Write-Output "Downloading $SSUFilename"
$latestSSU | Save-LatestUpdate -Path $path
$update=Get-MSCatalogUpdate -Search $item.searchstring | Where-Object Title -like "*$($item.SearchString)*" | Select-Object -First 1
}
$DestinationFolder="$folder\$SelectedProduct\$($update.title.Substring(0,7))"
New-Item -Path $DestinationFolder -ItemType Directory -ErrorAction Ignore | Out-Null
Write-Output "Downloading $($update.title) to $destinationFolder"
$update | Save-MSCatalogUpdate -Destination "$DestinationFolder" #-UseBits

#Download SSU
$update=Get-MSCatalogUpdate -Search $item.SSUSearchString | Select-Object -First 1
Write-Output "Downloading $($update.title) to $destinationFolder"
$update | Save-MSCatalogUpdate -Destination $DestinationFolder #-UseBits
}
#endregion

Write-Host "Job finished. Press enter to continue" -ForegroundColor Green
Read-Host

0 comments on commit affde4e

Please sign in to comment.