Skip to content

Commit 494babb

Browse files
authored
Merge pull request #524 from microsoft/dev
Dev
2 parents d2cf208 + ac38f94 commit 494babb

File tree

9 files changed

+120
-53
lines changed

9 files changed

+120
-53
lines changed

Scenarios/AzSHCI and AVD/Scenario.ps1

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
$ManagedDiskName = "AVD_OS_Disk_Windows11_m365"
1515
$Offer="windows11preview"
16-
$SKU="win11-21h2-avd-m365"
16+
$SKU="win11-22h2-avd-m365"
1717

1818
#Install Azure packages
1919
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
@@ -1440,12 +1440,12 @@
14401440
$OUPath="ou=workshop,dc=corp,dc=contoso,dc=com"
14411441
$names=(Get-ChildItem -Path "$env:UserProfile\Downloads\WVDBackups" -Filter *.htm).BaseName
14421442
foreach ($name in $names) {
1443-
New-GPO -Name $name | New-GPLink -Target $OUPath
1444-
#Import-GPO -BackupGpoName $name -TargetName $name -path "$env:UserProfile\Downloads\WVDBackups"
1443+
#create GPO and import to OU (uncomment if needed)
1444+
New-GPO -Name $name #| New-GPLink -Target $OUPath
1445+
Import-GPO -BackupGpoName $name -TargetName $name -path "$env:UserProfile\Downloads\WVDBackups"
14451446
}
14461447

1447-
#install FSLogix to session hosts (not needed, since in 21H2 agent is already present)
1448-
<#
1448+
#update FSLogix (if not needed, installer will gratefully shut down)
14491449
#create sessions
14501450
$Sessions=New-PSSession -ComputerName $VMs.VMName
14511451
foreach ($session in $Sessions){
@@ -1459,8 +1459,7 @@
14591459
}
14601460

14611461
#reboot machines
1462-
Restart-Computer -ComputerName $VMs.VMName -Protocol WSMan -Wait -For PowerShell
1463-
#>
1462+
#Restart-Computer -ComputerName $VMs.VMName -Protocol WSMan -Wait -For PowerShell
14641463

14651464
#Create users with password LS1setup!
14661465
New-ADUser -Name JohnDoe -AccountPassword (ConvertTo-SecureString "LS1setup!" -AsPlainText -Force) -Enabled $True -Path "ou=workshop,dc=corp,dc=contoso,dc=com"
@@ -1565,7 +1564,7 @@
15651564
Remove-AzResourceGroup -Name $AVDResourceGroupName -Force
15661565
#remove Azure Service Principal
15671566
$SP=Get-AzADServicePrincipal -DisplayName "Arc-for-servers"
1568-
Remove-AzADServicePrincipal -ObjectId $SP.Id -Force
1567+
Remove-AzADServicePrincipal -ObjectId $SP.Id
15691568
#remove VMs
15701569
foreach ($VM in $VMs){
15711570
$VMObject=Get-VM -CimSession (Get-ClusterNode -Cluster $ClusterName).Name -Name $VM.VMName -ErrorAction Ignore

Scenarios/AzSHCI and Kubernetes/Scenario.ps1

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,40 @@ Foreach ($VM in $VMs){
3131
# LabConfig
3232
$Servers="AksHCI1","AksHCI2"
3333
$ClusterName="AksHCI-Cluster"
34+
$windowsupdate=$false
3435

3536
# Install features for management on server
3637
Install-WindowsFeature -Name RSAT-DHCP,RSAT-Clustering,RSAT-Clustering-Mgmt,RSAT-Clustering-PowerShell,RSAT-Hyper-V-Tools
3738

38-
# Update servers
39-
Invoke-Command -ComputerName $servers -ScriptBlock {
40-
New-PSSessionConfigurationFile -RunAsVirtualAccount -Path $env:TEMP\VirtualAccount.pssc
41-
Register-PSSessionConfiguration -Name 'VirtualAccount' -Path $env:TEMP\VirtualAccount.pssc -Force
42-
} -ErrorAction Ignore
43-
# Run Windows Update via ComObject.
44-
Invoke-Command -ComputerName $servers -ConfigurationName 'VirtualAccount' {
45-
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
46-
$SearchCriteriaAllUpdates = "IsInstalled=0 and DeploymentAction='Installation' or
47-
IsPresent=1 and DeploymentAction='Uninstallation' or
48-
IsInstalled=1 and DeploymentAction='Installation' and RebootRequired=1 or
49-
IsInstalled=0 and DeploymentAction='Uninstallation' and RebootRequired=1"
50-
$SearchResult = $Searcher.Search($SearchCriteriaAllUpdates).Updates
51-
$Session = New-Object -ComObject Microsoft.Update.Session
52-
$Downloader = $Session.CreateUpdateDownloader()
53-
$Downloader.Updates = $SearchResult
54-
$Downloader.Download()
55-
$Installer = New-Object -ComObject Microsoft.Update.Installer
56-
$Installer.Updates = $SearchResult
57-
$Result = $Installer.Install()
58-
$Result
59-
}
60-
#remove temporary PSsession config
61-
Invoke-Command -ComputerName $servers -ScriptBlock {
62-
Unregister-PSSessionConfiguration -Name 'VirtualAccount'
63-
Remove-Item -Path $env:TEMP\VirtualAccount.pssc
39+
#update servers if requested
40+
if ($windowsupdate){
41+
# Update servers
42+
Invoke-Command -ComputerName $servers -ScriptBlock {
43+
New-PSSessionConfigurationFile -RunAsVirtualAccount -Path $env:TEMP\VirtualAccount.pssc
44+
Register-PSSessionConfiguration -Name 'VirtualAccount' -Path $env:TEMP\VirtualAccount.pssc -Force
45+
} -ErrorAction Ignore
46+
# Run Windows Update via ComObject.
47+
Invoke-Command -ComputerName $servers -ConfigurationName 'VirtualAccount' {
48+
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
49+
$SearchCriteriaAllUpdates = "IsInstalled=0 and DeploymentAction='Installation' or
50+
IsPresent=1 and DeploymentAction='Uninstallation' or
51+
IsInstalled=1 and DeploymentAction='Installation' and RebootRequired=1 or
52+
IsInstalled=0 and DeploymentAction='Uninstallation' and RebootRequired=1"
53+
$SearchResult = $Searcher.Search($SearchCriteriaAllUpdates).Updates
54+
$Session = New-Object -ComObject Microsoft.Update.Session
55+
$Downloader = $Session.CreateUpdateDownloader()
56+
$Downloader.Updates = $SearchResult
57+
$Downloader.Download()
58+
$Installer = New-Object -ComObject Microsoft.Update.Installer
59+
$Installer.Updates = $SearchResult
60+
$Result = $Installer.Install()
61+
$Result
62+
}
63+
#remove temporary PSsession config
64+
Invoke-Command -ComputerName $servers -ScriptBlock {
65+
Unregister-PSSessionConfiguration -Name 'VirtualAccount'
66+
Remove-Item -Path $env:TEMP\VirtualAccount.pssc
67+
}
6468
}
6569

6670
# Update servers with all updates (including preview)
@@ -740,6 +744,31 @@ kubectl -n azure-arc get deployments,pods
740744

741745
#endregion
742746

747+
#region deploy Open Service Mesh extension https://docs.microsoft.com/en-us/azure/azure-arc/kubernetes/tutorial-arc-enabled-open-service-mesh
748+
$ClusterName="AksHCI-Cluster"
749+
$resourcegroup="$ClusterName-rg"
750+
$KubernetesClusterName="demo"
751+
752+
$ExtensionName="openservicemesh-ext"
753+
754+
#register provider
755+
$Provider="Microsoft.Kubernetes"
756+
Register-AzResourceProvider -ProviderNamespace $Provider
757+
#wait for provider to finish registration
758+
do {
759+
$Status=Get-AzResourceProvider -ProviderNamespace $Provider
760+
Write-Output "Registration Status - $Provider : $(($status.RegistrationState -match 'Registered').Count)/$($Status.Count)"
761+
Start-Sleep 1
762+
} while (($status.RegistrationState -match "Registered").Count -ne ($Status.Count))
763+
764+
#deploy extension
765+
az k8s-extension create --cluster-type connectedClusters --cluster-name $KubernetesClusterName --resource-group $resourcegroup --extension-type Microsoft.openservicemesh --name $ExtensionName
766+
767+
#validate deployment (show azurepolicy extension)
768+
az k8s-extension show --name $ExtensionName --cluster-name $KubernetesClusterName --resource-group $resourcegroup --cluster-type connectedClusters | ConvertFrom-Json
769+
770+
#endregion
771+
743772
#region create Arc app service extension
744773
#https://docs.microsoft.com/en-us/azure/app-service/manage-create-arc-environment?tabs=powershell
745774
#looks like exstension fails https://github.com/Azure/azure-cli-extensions/issues/3661
@@ -916,6 +945,9 @@ $StorageContainerPath="c:\ClusterStorage\AKSContainer"
916945
$StorageContainerVolumeName=$StorageContainerPath | Split-Path -Leaf
917946
$StorageContainerSize=1TB
918947

948+
#add kubectl to system environment variable, so it can be run by simply typing kubectl
949+
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+';c:\program files\AksHci')
950+
919951
#Create volume for AKS if does not exist
920952
if (-not (Get-Volume -FriendlyName $StorageContainerVolumeName -CimSession $ClusterName -ErrorAction SilentlyContinue)) {
921953
New-Volume -FriendlyName $StorageContainerVolumeName -CimSession $ClusterName -Size $StorageContainerSize -StoragePoolFriendlyName S2D*

Scenarios/AzSHCI and Kubernetes/readme.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ https://aka.ms/AKSonHCI-Docs
2121
Note: please download latest [WSLab](https://aka.ms/wslab/download) as there is new VMProcessorCount value Max, that will configure maximum available LP to VMs.
2222

2323
```PowerShell
24-
$LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!' ; <#Prefix = 'WSLab-'#> ; DCEdition='4'; Internet=$true ; TelemetryLevel='Full' ; TelemetryNickname='' ; AdditionalNetworksConfig=@(); VMs=@()}
24+
$LabConfig=@{ManagementSubnetIDs=0..1 ; DomainAdminName='LabAdmin'; AdminPassword='LS1setup!' ; Prefix = 'MSLab-' ; DCEdition='4'; Internet=$true ; TelemetryLevel='Full' ; TelemetryNickname='' ; AdditionalNetworksConfig=@(); VMs=@()}
2525
2626
#2 nodes for AzSHCI Cluster
27-
1..2 | ForEach-Object {$VMNames="AzSHCI" ; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'AzSHCI20H2_G2.vhdx' ; HDDNumber = 4 ; HDDSize= 4TB ; MemoryStartupBytes= 24GB; VMProcessorCount="Max" ; NestedVirt=$true}}
27+
1..2 | ForEach-Object {$VMNames="AksHCI" ; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'AzSHCI21H2_G2.vhdx' ; HDDNumber = 4 ; HDDSize= 4TB ; MemoryStartupBytes= 24GB; VMProcessorCount="Max" ; NestedVirt=$true ; VirtualTPM=$true}}
2828
29-
#Windows 10 management machine (for Windows Admin Center)
30-
$LabConfig.VMs += @{ VMName = 'Win10'; ParentVHD = 'Win1020H1_G2.vhdx' ; AddToolsVHD = $True ; MGMTNICs=1 }
29+
#or 2 nodes for Windows Server 2022
30+
#1..2 | ForEach-Object {$VMNames="AksHCI" ; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'Win2022Core_G2.vhdx' ; HDDNumber = 4 ; HDDSize= 4TB ; MemoryStartupBytes= 24GB; VMProcessorCount="Max" ; NestedVirt=$true ; VirtualTPM=$true}}
3131
3232
#Windows Admin Center gateway
33-
#$LabConfig.VMs += @{ VMName = 'WACGW' ; ParentVHD = 'Win2019Core_G2.vhdx' ; MGMTNICs=1 }
33+
#$LabConfig.VMs += @{ VMName = 'WACGW' ; ParentVHD = 'Win2022Core_G2.vhdx' ; MGMTNICs=1 }
34+
35+
#Management machine
36+
$LabConfig.VMs += @{ VMName = 'Management' ; ParentVHD = 'Win2022_G2.vhdx' ; MGMTNICs=1 }
3437
3538
```
3639

Scripts/1_Prereq.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ if((Get-TelemetryLevel) -in $TelemetryEnabledLevels) {
308308

309309
# finishing
310310
WriteInfo "Script finished at $(Get-date) and took $(((get-date) - $StartDateTime).TotalMinutes) Minutes"
311+
311312
Stop-Transcript
312-
WriteSuccess "Press enter to continue..."
313-
Read-Host | Out-Null
313+
314+
If (!$LabConfig.AutoClosePSWindows) {
315+
WriteSuccess "Press enter to continue..."
316+
Read-Host | Out-Null
317+
}

Scripts/2_CreateParentDisks.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,13 @@ If (-not $isAdmin) {
11201120
<# 0 #> New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Cleanup .\Temp\ 1_Prereq.ps1 2_CreateParentDisks.ps1 and rename 3_deploy.ps1 to just deploy.ps1"
11211121
<# 1 #> New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Keep files (in case DC was not created sucessfully)"
11221122
)
1123-
$response = $host.UI.PromptForChoice("Unnecessary files cleanup","Do you want to cleanup unnecessary files and folders?", $options, 0 <#default option#>)
1123+
1124+
If (!$LabConfig.AutoCleanUp) {
1125+
$response = $host.UI.PromptForChoice("Unnecessary files cleanup","Do you want to cleanup unnecessary files and folders?", $options, 0 <#default option#>)
1126+
}
1127+
else {
1128+
$response = 0
1129+
}
11241130

11251131
If ($response -eq 1){
11261132
$renamed = $false
@@ -1201,8 +1207,11 @@ If (-not $isAdmin) {
12011207
Send-TelemetryEvents -Events $events | Out-Null
12021208
}
12031209

1204-
Stop-Transcript
1210+
Stop-Transcript
1211+
1212+
If (!$LabConfig.AutoClosePSWindows) {
12051213
WriteSuccess "Job Done. Press enter to continue..."
12061214
Read-Host | Out-Null
1215+
}
12071216

1208-
#endregion
1217+
#endregion

Scripts/3_Deploy.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,11 +1808,13 @@ If (-not $isAdmin) {
18081808
Send-TelemetryEvents -Events $vmDeploymentEvents | Out-Null
18091809
}
18101810

1811-
#write how much it took to deploy
1812-
WriteInfo "Script finished at $CheckPointTime and took $(($CheckPointTime - $StartDateTime).TotalMinutes) Minutes"
1811+
#write how much it took to deploy
1812+
WriteInfo "Script finished at $CheckPointTime and took $(($CheckPointTime - $StartDateTime).TotalMinutes) Minutes"
18131813

1814-
Stop-Transcript
1814+
Stop-Transcript
18151815

1816-
WriteSuccess "Press enter to continue ..."
1816+
If (!$LabConfig.AutoClosePSWindows) {
1817+
WriteSuccess "Press enter to continue..."
18171818
Read-Host | Out-Null
1819+
}
18181820
#endregion

Scripts/LabConfig.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ $LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'M
4646
Linux=$false; # (Optional) If set to $true, required prerequisities for building Linux images with Packer will be configured.
4747
LinuxAdminName="linuxadmin"; # (Optional) If set, local user account with that name will be created in Linux image. If not, DomainAdminName will be used as a local account.
4848
SshKeyPath="$($env:USERPROFILE)\.ssh\id_rsa" # (Optional) If set, specified SSH key will be used to build and access Linux images.
49+
AutoClosePSWindows=$false; # (Optional) If set, the PowerShell console windows will automatically close once the script has completed successfully. Best suited for use in automated deployments.
50+
AutoCleanUp=$false; # (Optional) If set, after creating initial parent disks, files that are no longer necessary will be cleaned up. Best suited for use in automated deployments.
4951
AdditionalNetworksConfig=@(); # Just empty array for config below
5052
VMs=@(); # Just empty array for config below
5153
}
@@ -206,6 +208,15 @@ $LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'M
206208
SshKeyPath (optional)
207209
Example: SshKeyPath="$($env:USERPROFILE)\.ssh\id_rsa"
208210
If configured, existing SSH key will be used for building and connecting to Linux images. If not, 0_Prereq.ps1 will generate a new SSH key pair and store it locally in LAB folder.
211+
212+
AutoStartAfterDeploy (optional)
213+
Example: AutoClosePSWindows=$true
214+
If set to true, the PowerShell console windows will automatically close once the script has completed successfully. Best suited for use in automated deployments.
215+
216+
AutoCleanup (optional)
217+
Example: AutoCleanUp=$true
218+
If set to true, after creating initial parent disks, files that are no longer necessary will be cleaned up. Best suited for use in automated deployments.
219+
209220
#>
210221
#endregion
211222

Tools/CreateParentDisk.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ If (-not $isAdmin) {
161161
20348 {
162162
"AzSHCI21H2_G2.vhdx"
163163
}
164+
22621 {
165+
"AzSHCI22H2_G2.vhdx"
166+
}
164167
}
165168
if ($BuildNumber -GT 20348){
166169
$tempvhdname="AzSHCIInsider_$BuildNumber.vhdx"
@@ -296,8 +299,11 @@ If (-not $isAdmin) {
296299
22000 {
297300
"Win1121H2_G2.vhdx"
298301
}
302+
22621 {
303+
"Win1122H2_G2.vhdx"
304+
}
299305
}
300-
if ($BuildNumber -GT 22000){
306+
if ($BuildNumber -GT 22621){
301307
$tempvhdname="Win11Insider_$BuildNumber.vhdx"
302308
}
303309
}

Tools/DownloadLatestCUs.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ $Products+=@{Product="Azure Stack HCI 21H2 and Windows Server 2022" ;SearchStrin
4343
$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" ; ID="Azure Stack HCI"}
4444
$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 Systems" ; ID="Windows Server 2019"}
4545
$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 Systems" ; ID="Windows Server 2016"}
46-
$Products+=@{Product="Windows 10 21H1" ;SearchString="Cumulative Update for Windows 10 Version 21H1 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows 10 Version 21H1 for x64-based Systems" ; ID="Windows 10, version 1903 and later"}
47-
$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" ; ID="Windows 10, version 1903 and later"}
48-
$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" ; ID="Windows 10, version 1903 and later"}
49-
$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" ; ID="Windows 10, version 1903 and later"}
46+
$Products+=@{Product="Windows 11 22H2" ;SearchString="Cumulative Update for Windows 11 Version 22H2 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows 11 Version 22H2 for x64-based Systems" ; ID="Windows 11"}
47+
$Products+=@{Product="Windows 10 21H2" ;SearchString="Cumulative Update for Windows 10 Version 21H2 for x64-based Systems" ;SSUSearchString="Servicing Stack Update for Windows 10 Version 21H2 for x64-based Systems" ; ID="Windows 10, version 1903 and later, Windows 10 LTSB"}
48+
$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" ; ID="Windows 10, version 1903 and later"}
49+
$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" ; ID="Windows 10, version 1903 and later"}
50+
$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" ; ID="Windows 10, version 1903 and later"}
5051

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

0 commit comments

Comments
 (0)