Skip to content

Commit

Permalink
support for external NICs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromirk committed Aug 25, 2021
1 parent 6f48550 commit 06d4d94
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
21 changes: 19 additions & 2 deletions Scripts/3_Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,26 @@ If (-not $isAdmin) {
WriteInfoHighlighted "Creating Switch"
WriteInfo "`t Checking if $SwitchName already exists..."

if ((Get-VMSwitch -Name $SwitchName -ErrorAction Ignore) -eq $Null){
if (-not (Get-VMSwitch -Name $SwitchName -ErrorAction Ignore)){
WriteInfo "`t Creating $SwitchName..."
New-VMSwitch -SwitchType Private -Name $SwitchName
if ($LabConfig.SwitchNICs){
#test if NICs are not already connected to another switch
$VMSComponentStatus=Get-NetAdapterBinding -Name $LabConfig.SwitchNICs -ComponentID vms_pp
if (($VMSComponentStatus).Enabled -contains $true){
$BoundNICs=$VMSComponentStatus | Where-Object Enabled -eq $true
$InterfaceGUIDs=(Get-NetAdapter -Name $BoundNICs.Name).InterfaceGUID
$vSwitches=ForEach ($InterfaceGUID in $InterfaceGUIDs){Get-VMSwitch | Where-Object NetAdapterInterfaceGuid -Contains $InterfaceGuid}
WriteError "Following NICs are already bound to a Virtual Switch:"
$BoundNICs
WriteError "Virtual Switch list:"
$vSwitches | Select-Object Name,NetAdapterInterfaceDescriptions
WriteErrorAndExit "At least one NIC is connected to existing Virtual Switch, different than specified in Labconfig ($SwitchName)"
}else{
New-VMSwitch -SwitchType External -Name $SwitchName -EnableEmbeddedTeaming $true -EnableIov $true -NetAdapterName $LabConfig.SwitchNics -AllowManagementOS $False
}
}else{
New-VMSwitch -SwitchType Private -Name $SwitchName
}
}else{
$SwitchNameExists=$True
WriteInfo "`t $SwitchName exists. Looks like lab with same prefix exists. "
Expand Down
13 changes: 7 additions & 6 deletions Scripts/LabConfig.ps1
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#basic config for Windows Server 2019, that creates VMs for S2D Hyperconverged scenario https://github.com/Microsoft/MSLab/tree/master/Scenarios/S2D%20Hyperconverged

$LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'MSLab-' ; DCEdition='4'; Internet=$true ; AdditionalNetworksConfig=@(); VMs=@()}
# Windows Server 2019
1..4 | ForEach-Object {$VMNames="S2D"; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'Win2019Core_G2.vhdx'; SSDNumber = 0; SSDSize=800GB ; HDDNumber = 12; HDDSize= 4TB ; MemoryStartupBytes= 512MB }}
# Or Azure Stack HCI
# Windows Server 2022
1..4 | ForEach-Object {$VMNames="S2D"; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'Win2022Core_G2.vhdx'; SSDNumber = 0; SSDSize=800GB ; HDDNumber = 12; HDDSize= 4TB ; MemoryStartupBytes= 512MB }}
# Or Azure Stack HCI 20H2
#1..4 | ForEach-Object {$VMNames="AzSHCI"; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'AzSHCI20H2_G2.vhdx'; SSDNumber = 0; SSDSize=800GB ; HDDNumber = 12; HDDSize= 4TB ; MemoryStartupBytes= 1GB }}
# Or Windows Server 2022
#1..4 | ForEach-Object {$VMNames="S2D"; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'Win2022Core_G2.vhdx'; SSDNumber = 0; SSDSize=800GB ; HDDNumber = 12; HDDSize= 4TB ; MemoryStartupBytes= 512MB }}
# Or Windows Server 2019
#1..4 | ForEach-Object {$VMNames="S2D"; $LABConfig.VMs += @{ VMName = "$VMNames$_" ; Configuration = 'S2D' ; ParentVHD = 'Win2019Core_G2.vhdx'; SSDNumber = 0; SSDSize=800GB ; HDDNumber = 12; HDDSize= 4TB ; MemoryStartupBytes= 512MB }}


### HELP ###

#If you need more help or different configuration options, ping me at jaromirk@microsoft.com
#If you need more help or different configuration options, ping us at jaromir.kaspar@dell.com or vlmach@microsoft.com

#region Same as above, but with more explanation
<#
Expand All @@ -20,6 +20,7 @@ $LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'M
AdminPassword='LS1setup!'; # Used during 2_CreateParentDisks. If changed after, it will break the functionality of 3_Deploy.ps1
Prefix = 'MSLab-'; # (Optional) All VMs and vSwitch are created with this prefix, so you can identify the lab. If not specified, Lab folder name is used
SwitchName = 'LabSwitch'; # (Optional) Name of vSwitch
SwitchNICs = 'NIC1",NIC2" ; # (Optional) Adds these NICs to vSwitch (without connecting host).
SecureBoot=$true; # (Optional) Useful when testing unsigned builds (Useful for MS developers for daily builds)
DCEdition='4'; # 4 for DataCenter or 3 for DataCenterCore
InstallSCVMM='No'; # (Optional) Yes/Prereqs/SQL/ADK/No
Expand Down

0 comments on commit 06d4d94

Please sign in to comment.