Skip to content

Commit

Permalink
Merge pull request #504 from microsoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
machv authored Mar 10, 2022
2 parents bf49891 + bfbef07 commit 100c365
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
28 changes: 28 additions & 0 deletions Scripts/3_Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,34 @@ If (-not $isAdmin) {
$global:IP++
}

if($VMConfig.AdditionalNetworkAdapters) {
$networks = $VMConfig.AdditionalNetworkAdapters
if($networks -isnot [array]) {
$networks = @($networks)
}

foreach ($network in $networks) {
$switch = Get-VMSwitch -Name $network.VirtualSwitchName -ErrorAction SilentlyContinue
if(-not $switch) {
WriteErrorAndExit "Hyper-V switch $($network.VirtualSwitchName) not found."
}

$adapter = $vmtemp | Add-VMNetworkAdapter -SwitchName $network.VirtualSwitchName -Passthru

if($network.Mac -and $network.Mac -match "^([0-9A-F][0-9A-F]-){5}[0-9A-F][0-9A-F]$") {
$adapter | Set-VMNetworkAdapter -StaticMacAddress $network.Mac
}

if($network.VlanId -and $network.VlanId -ne 0) {
$adapter | Set-VMNetworkAdapterVlan -VlanId $network.VlanId -Access
}

if($network.IpConfiguration -and $network.IpConfiguration -ne "DHCP" -and $network.IpConfiguration -is [Hashtable]) {
$adapter | Set-VMNetworkConfiguration -IPAddress $network.IpConfiguration.IpAddress -Subnet $network.IpConfiguration.Subnet
}
}
}

#Generate DSC Config
if ($VMConfig.DSCMode -eq 'Pull'){
WriteInfo "`t Setting DSC Mode to Pull"
Expand Down
13 changes: 12 additions & 1 deletion Scripts/LabConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ $LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'M
# 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 us at [email protected] or [email protected]
Expand Down Expand Up @@ -239,6 +238,18 @@ $LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'M
AdditionalNetworks (Optional)
$True - Additional networks (configured in AdditonalNetworkConfig) are added
AdditionalNetworkAdapters (Optional) - Hashtable or array if multiple network adapters should be connected to this virtual machine
@{
VirtualSwitchName (Mandatory) - Name of the Hyper-V Switch to witch the adapter will be connected
Mac (Optional) - Static MAC address of the interface otherwise default will be generated
VlanId (Optional) - VLAN ID for this adapter
IpConfiguration (Optional) - DHCP or hastable with specific IP configuration
@{
IpAddress (Mandatory) - Static IP Address that would be injected to the OS
Subnet (Mandatory)
}
}
DSCMode (Optional)
If 'Pull', VMs will be configured to Pull config from DC.
Expand Down

0 comments on commit 100c365

Please sign in to comment.