|
| 1 | +# Testing Windows Server Insider Preview |
| 2 | + |
| 3 | +## About the lab |
| 4 | + |
| 5 | +https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewserver |
| 6 | + |
| 7 | +Blogpost: https://techcommunity.microsoft.com/discussions/windowsserverinsiders/announcing-windows-server-vnext-preview-build-29621/4536572 |
| 8 | + |
| 9 | + |
| 10 | +## Labconfig |
| 11 | + |
| 12 | +```PowerShell |
| 13 | +$LabConfig=@{AllowedVLANs="1-10,711-719" ; DomainAdminName='LabAdmin'; AdminPassword='LS1setup!' ; DCEdition='4'; Internet=$true; AdditionalNetworksConfig=@(); VMs=@()} |
| 14 | +
|
| 15 | +#Windows Server Insider S2D nodes |
| 16 | +$LABConfig.VMs += @{ VMName = "S2D1" ; Configuration = 'S2D' ; ParentVHD = 'WinSrvInsiderCore_29621.vhdx' ; HDDNumber = 4 ; HDDSize= 1TB ; MemoryStartupBytes= 4GB; VMProcessorCount="MAX" ; vTPM=$true ; NestedVirt=$true } |
| 17 | +$LABConfig.VMs += @{ VMName = "S2D2" ; Configuration = 'S2D' ; ParentVHD = 'WinSrvInsiderCore_29621.vhdx' ; HDDNumber = 4 ; HDDSize= 1TB ; MemoryStartupBytes= 4GB; VMProcessorCount="MAX" ; vTPM=$true ; NestedVirt=$true } |
| 18 | +
|
| 19 | +#Management machine |
| 20 | +$LabConfig.VMs += @{ VMName = 'Management' ; ParentVHD = 'WinSrvInsider_29621.vhdx'; MGMTNICs=1 ; AddToolsVHD=$True } |
| 21 | + |
| 22 | +``` |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## Prerequisites |
| 30 | + |
| 31 | +### Create Insider Lab Environment |
| 32 | + |
| 33 | +To create insider parent image, download latest iso from [Windows Server Insiders Downloads](https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewserver) and then follow steps in [01-Creating First Lab](../../HandsOnLabs/01-CreatingFirstLab/readme.md) with Labconfig above. |
| 34 | + |
| 35 | +### Build your cluster |
| 36 | + |
| 37 | +Once you're logged in the management machine, simply paste following PowerShell to build simple 2-node cluster |
| 38 | + |
| 39 | +```PowerShell |
| 40 | +#region Variables |
| 41 | + #servers list |
| 42 | + $Servers="S2D1","S2D2" |
| 43 | + #Cluster Name |
| 44 | + $ClusterName="S2D-Cluster" |
| 45 | + #Witness Server |
| 46 | + $WitnessServer="DC" |
| 47 | +#endregion |
| 48 | +
|
| 49 | +#region install keys and activate servers |
| 50 | +
|
| 51 | +$LicenseKey="2KNJJ-33Y9H-2GXGX-KMQWH-G6H67" |
| 52 | +
|
| 53 | + cscript c:\windows\system32\slmgr.vbs /ipk $using:LicenseKey |
| 54 | + cscript c:\windows\system32\slmgr.vbs /ato |
| 55 | +
|
| 56 | +Invoke-Command -ComputerName $Servers -ScriptBlock { |
| 57 | + cscript c:\windows\system32\slmgr.vbs /ipk $using:LicenseKey |
| 58 | + cscript c:\windows\system32\slmgr.vbs /ato |
| 59 | +} |
| 60 | +
|
| 61 | +#check status |
| 62 | +Get-CimInstance SoftwareLicensingProduct -CimSession $Servers | |
| 63 | + Where-Object { $_.PartialProductKey -and $_.ApplicationID -eq '55c92734-d682-4d71-983e-d6ec3f16059f' } | |
| 64 | + Select-Object Name, Description, LicenseStatus, PartialProductKey, PSComputerName, |
| 65 | + @{N='LicenseStatusText';E={ |
| 66 | + switch ($_.LicenseStatus) { |
| 67 | + 0 {'Unlicensed'} |
| 68 | + 1 {'Licensed'} |
| 69 | + 2 {'OOBGrace'} |
| 70 | + 3 {'OOTGrace'} |
| 71 | + 4 {'NonGenuineGrace'} |
| 72 | + 5 {'Notification'} |
| 73 | + 6 {'ExtendedGrace'} |
| 74 | + default {'Unknown'} |
| 75 | + } |
| 76 | + }} |
| 77 | +#endregion |
| 78 | +
|
| 79 | +#region install required features |
| 80 | + #install features for management (assuming you are running these commands on Windows Server with GUI) |
| 81 | + Install-WindowsFeature -Name NetworkATC,RSAT-Clustering,RSAT-Clustering-Mgmt,RSAT-Clustering-PowerShell,RSAT-Hyper-V-Tools,RSAT-Feature-Tools-BitLocker-BdeAducExt,RSAT-AD-PowerShell,RSAT-AD-AdminCenter,RSAT-DHCP,RSAT-DNS-Server |
| 82 | +
|
| 83 | + #install roles and features on servers |
| 84 | + #install Hyper-V using DISM if Install-WindowsFeature fails (if nested virtualization is not enabled install-windowsfeature fails) |
| 85 | + Invoke-Command -ComputerName $servers -ScriptBlock { |
| 86 | + $Result=Install-WindowsFeature -Name "Hyper-V" -ErrorAction SilentlyContinue |
| 87 | + if ($result.ExitCode -eq "failed"){ |
| 88 | + Enable-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V -Online -NoRestart |
| 89 | + } |
| 90 | + } |
| 91 | + #define and install other features |
| 92 | + $features="Failover-Clustering","RSAT-Clustering-PowerShell","Hyper-V-PowerShell","NetworkATC","Data-Center-Bridging","RSAT-DataCenterBridging-LLDP-Tools","FS-SMBBW","System-Insights","RSAT-System-Insights" |
| 93 | + Invoke-Command -ComputerName $servers -ScriptBlock {Install-WindowsFeature -Name $using:features} |
| 94 | +#endregion |
| 95 | +
|
| 96 | +#region restart servers to apply |
| 97 | + Restart-Computer $servers -Protocol WSMan -Wait -For PowerShell -Force |
| 98 | + Start-Sleep 20 #Failsafe as Hyper-V needs 2 reboots and sometimes it happens, that during the first reboot the restart-computer evaluates the machine is up |
| 99 | + #make sure computers are restarted |
| 100 | + Foreach ($Server in $Servers){ |
| 101 | + do{$Test= Test-NetConnection -ComputerName $Server -CommonTCPPort WINRM}while ($test.TcpTestSucceeded -eq $False) |
| 102 | + } |
| 103 | +#endregion |
| 104 | +
|
| 105 | +#region Create cluster |
| 106 | + #Create Cluster |
| 107 | + New-Cluster -Name $ClusterName -Node $servers |
| 108 | + Start-Sleep 5 |
| 109 | + Clear-DnsClientCache |
| 110 | +
|
| 111 | + ##Configure Witness on WitnessServer |
| 112 | + #Create new directory |
| 113 | + $WitnessName=$Clustername+"Witness" |
| 114 | + Invoke-Command -ComputerName $WitnessServer -ScriptBlock {new-item -Path c:\Shares -Name $using:WitnessName -ItemType Directory -ErrorAction Ignore} |
| 115 | + $accounts=@() |
| 116 | + $accounts+="$env:userdomain\$ClusterName$" |
| 117 | + $accounts+="$env:userdomain\$env:USERNAME" |
| 118 | + #$accounts+="$env:userdomain\Domain Admins" |
| 119 | + New-SmbShare -Name $WitnessName -Path "c:\Shares\$WitnessName" -FullAccess $accounts -CimSession $WitnessServer |
| 120 | + #Set NTFS permissions |
| 121 | + Invoke-Command -ComputerName $WitnessServer -ScriptBlock {(Get-SmbShare $using:WitnessName).PresetPathAcl | Set-Acl} |
| 122 | + #Set Quorum |
| 123 | + Set-ClusterQuorum -Cluster $ClusterName -FileShareWitness "\\$WitnessServer\$WitnessName" |
| 124 | +#endregion |
| 125 | +
|
| 126 | +#region Configure networking with NetATC https://techcommunity.microsoft.com/t5/networking-blog/network-atc-what-s-coming-in-azure-stack-hci-22h2/ba-p/3598442 |
| 127 | + #make sure NetATC,FS-SMBBW and other required features are installed on servers |
| 128 | + Invoke-Command -ComputerName $Servers -ScriptBlock { |
| 129 | + Install-WindowsFeature -Name NetworkATC,Data-Center-Bridging,RSAT-Clustering-PowerShell,RSAT-Hyper-V-Tools,FS-SMBBW |
| 130 | + } |
| 131 | +
|
| 132 | + #in virtual environment, then skip RDMA config |
| 133 | +
|
| 134 | + Import-Module NetworkATC |
| 135 | + #virtual environment (skipping RDMA config) |
| 136 | + $AdapterOverride = New-NetIntentAdapterPropertyOverrides |
| 137 | + $AdapterOverride.NetworkDirect = 0 |
| 138 | + Add-NetIntent -ClusterName $ClusterName -Name ConvergedIntent -Management -Compute -Storage -AdapterName "Ethernet","Ethernet 2" -AdapterPropertyOverrides $AdapterOverride -Verbose #-StorageVlans 1,2 |
| 139 | +
|
| 140 | +
|
| 141 | + #check |
| 142 | + Start-Sleep 20 #let intent propagate a bit |
| 143 | + Write-Output "applying intent" |
| 144 | + do { |
| 145 | + $status=Get-NetIntentStatus -ClusterName $ClusterName |
| 146 | + Write-Host "." -NoNewline |
| 147 | + Start-Sleep 5 |
| 148 | + } while ($status.ConfigurationStatus -contains "Provisioning" -or $status.ConfigurationStatus -contains "Retrying") |
| 149 | +
|
| 150 | + #remove if necessary |
| 151 | + <# |
| 152 | + Invoke-Command -ComputerName $servers[0] -ScriptBlock { |
| 153 | + $intents = Get-NetIntent |
| 154 | + foreach ($intent in $intents){ |
| 155 | + Remove-NetIntent -Name $intent.IntentName |
| 156 | + } |
| 157 | + } |
| 158 | + #> |
| 159 | +
|
| 160 | + #if deploying in VMs, some nodes might fail (quarantined state) and even CNO can go to offline ... go to cluadmin and fix |
| 161 | + #Get-ClusterNode -Cluster $ClusterName | Where-Object State -eq down | Start-ClusterNode -ClearQuarantine |
| 162 | +#endregion |
| 163 | +
|
| 164 | +#region Enable S2D |
| 165 | + #Enable-ClusterS2D |
| 166 | + Enable-ClusterS2D -CimSession $ClusterName -confirm:0 -Verbose |
| 167 | +
|
| 168 | +#endregion |
| 169 | +
|
| 170 | +#region create sample volumes |
| 171 | + #create 1TB volume on each node |
| 172 | + foreach ($Server in $Servers){ |
| 173 | + New-Volume -StoragePoolFriendlyName "S2D on $ClusterName" -FriendlyName $Server -Size 1TB -CimSession $ClusterName |
| 174 | + } |
| 175 | +
|
| 176 | + #align volumes ownership to with servers |
| 177 | + foreach ($Server in $Servers){ |
| 178 | + Move-ClusterSharedVolume -Name "Cluster Virtual Disk ($Server)" -Node $Server -Cluster $ClusterName |
| 179 | + } |
| 180 | +#endregion |
| 181 | +
|
| 182 | +
|
| 183 | +
|
| 184 | +``` |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | +## Trusted Launch for virtual machines (TVMs) |
| 190 | + |
| 191 | +More information about Trusted Launch - https://techcommunity.microsoft.com/blog/windowsservernewsandbestpractices/announcing-trusted-launch-for-virtual-machines-for-windows-server-insiders/4537082 |
| 192 | + |
| 193 | +### Enable TVM feature |
| 194 | + |
| 195 | +```PowerShell |
| 196 | +$Servers="S2D1","S2D2" |
| 197 | +
|
| 198 | +Invoke-command -ComputerName $Servers -ScriptBlock { |
| 199 | + #Set registry keys |
| 200 | + New-Item -Path "HKLM:\SOFTWARE\Microsoft\AszIgvmAgent" -Force |
| 201 | + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\AszIgvmAgent" -Name "TvmWinServer" -Value 1 -PropertyType DWord -Force |
| 202 | + #enable feature |
| 203 | + Enable-WindowsOptionalFeature -Online -FeatureName "IsolatedGuestVm" -NoRestart |
| 204 | +} |
| 205 | +
|
| 206 | +``` |
| 207 | + |
| 208 | +### Validate if TVM is running |
| 209 | + |
| 210 | +```PowerShell |
| 211 | + Get-Service -ComputerName $Servers -Name "IGVmAgent" |
| 212 | +
|
| 213 | +``` |
| 214 | + |
| 215 | +### Create VM |
| 216 | + |
| 217 | +```PowerShell |
| 218 | + New-VM -Name "TVMTest01" -Generation 2 -GuestStateIsolationType TrustedLaunch -SwitchName (get-virtualswitch -cimsession $Servers[0]).Name -Path C:\ClusterStorage\S2D1\ -CimSession $Servers[0] |
| 219 | + #add as Highly Available |
| 220 | + Add-ClusterVirtualMachineRole -VirtualMachine "TVMTest01" -Cluster $ClusterName |
| 221 | + #Start |
| 222 | + Start-ClusterGroup -Name "TVMTest01" -Cluster $ClusterName |
| 223 | +``` |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | +### Test TVM - disable IGVmAgent |
| 228 | + |
| 229 | +```PowerShell |
| 230 | + Invoke-Command -ComputerName $Servers -ScriptBlock { |
| 231 | + Stop-Service -Name "IGVmAgent" |
| 232 | + } |
| 233 | + #restart VMV |
| 234 | + Stop-ClusterGroup -Name "TVMTest01" -Cluster $ClusterName |
| 235 | + Start-ClusterGroup -Name "TVMTest01" -Cluster $ClusterName |
| 236 | +
|
| 237 | +``` |
| 238 | + |
| 239 | + |
| 240 | + |
| 241 | +### Test TVM - enable IGVmAgent Again |
| 242 | + |
| 243 | +```PowerShell |
| 244 | + Invoke-Command -ComputerName $Servers -ScriptBlock { |
| 245 | + Start-Service -Name "IGVmAgent" |
| 246 | + } |
| 247 | + #restart VMV |
| 248 | + Start-ClusterGroup -Name "TVMTest01" -Cluster $ClusterName |
| 249 | +
|
| 250 | +``` |
| 251 | + |
| 252 | + |
| 253 | + |
| 254 | +## Quick Machine recovery |
| 255 | + |
| 256 | +https://learn.microsoft.com/en-us/windows/configuration/quick-machine-recovery/ |
| 257 | + |
| 258 | + |
| 259 | +```PowerShell |
| 260 | +#run from management machine |
| 261 | +#Enable test mode |
| 262 | +reagentc.exe /SetRecoveryTestmode |
| 263 | +#Configure Windows to boot to Windows Recovery Environment on the next boot: |
| 264 | +reagentc.exe /BootToRe |
| 265 | +#reboot machine |
| 266 | +Restart-Computer |
| 267 | +
|
| 268 | +``` |
| 269 | + |
| 270 | + |
| 271 | + |
0 commit comments