From f5789813123f607599e85987cc781210043f4f2a Mon Sep 17 00:00:00 2001 From: Matt McSpirit Date: Thu, 20 Mar 2025 12:21:44 -0700 Subject: [PATCH 1/3] Update LabConfig.ps1 Adding option to make DHCP Scope inactive. Default will be $true and 'Active' --- Scripts/LabConfig.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/LabConfig.ps1 b/Scripts/LabConfig.ps1 index a026d3e2..825d7829 100644 --- a/Scripts/LabConfig.ps1 +++ b/Scripts/LabConfig.ps1 @@ -37,6 +37,7 @@ $LabConfig=@{AllowedVLANs="1-10,711-719" ; DomainAdminName='LabAdmin'; AdminPass EnableGuestServiceInterface=$false; # (Optional) If True, then Guest Services integration component will be enabled on all VMs. DCVMProcessorCount=2; # (Optional) 2 is default. If specified more/less, processorcount will be modified. DHCPscope="10.0.0.0"; # (Optional) 10.0.0.0 is configured if nothing is specified. Scope has to end with .0 (like 10.10.10.0). It's always /24 + DHCPscopeActive=$true; # (Optional) If set to $false, DHCP Scope is created, but set to 'Inactive' DCVMVersion="9.0"; # (Optional) Latest is used if nothing is specified. Make sure you use values like "8.0","8.3","9.0" TelemetryLevel=""; # (Optional) If configured, script will stop prompting you for telemetry. Values are "None","Basic","Full" TelemetryNickname=""; # (Optional) If configured, telemetry will be sent with NickName to correlate data to specified NickName. So when leaderboards will be published, MSLab users will be able to see their own stats From a1f8c0af9c6d7b2877bbaf80ae3d3eab133c128f Mon Sep 17 00:00:00 2001 From: Matt McSpirit Date: Thu, 20 Mar 2025 12:54:49 -0700 Subject: [PATCH 2/3] Update DHCP Scope State --- Scripts/0_DCHydrate.ps1 | 7 +++++-- Scripts/3_Deploy.ps1 | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Scripts/0_DCHydrate.ps1 b/Scripts/0_DCHydrate.ps1 index dea0c3ca..e59a9f2e 100644 --- a/Scripts/0_DCHydrate.ps1 +++ b/Scripts/0_DCHydrate.ps1 @@ -96,6 +96,9 @@ function Hydrate-DC { [parameter(Mandatory=$true)] [string]$DhcpScope, + [parameter(Mandatory=$true)] + [string]$DhcpScopeState, + [parameter(Mandatory=$true)] [string]$AdminPassword) @@ -396,8 +399,8 @@ function Hydrate-DC { IPEndRange = ($DhcpScope+"254") Name = 'ManagementScope' SubnetMask = '255.255.255.0' - LeaseDuration = '00:08:00' - State = 'Active' + LeaseDuration = ((New-TimeSpan -Hours 8).ToString()) + State = $DHCPScopeState AddressFamily = 'IPv4' DependsOn = "[Service]DHCPServer" } diff --git a/Scripts/3_Deploy.ps1 b/Scripts/3_Deploy.ps1 index 88afbeb1..afcef0b5 100644 --- a/Scripts/3_Deploy.ps1 +++ b/Scripts/3_Deploy.ps1 @@ -1287,7 +1287,14 @@ If (-not $isAdmin) { $VMPath="$PSScriptRoot\LAB\" $HydrationSwitchname="DC_HydrationSwitch_$([guid]::NewGuid())" - Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VMPath $VMPath -Switchname $HydrationSwitchname -TimeZone $TimeZone -DHCPScope $LabConfig.DHCPscope -AdminPassword $LabConfig.AdminPassword + if ($LabConfig.DHCPscopeActive -eq $false){ + $DHCPScopeState = 'Inctive' + } + else { + $DHCPScopeState = 'Active' + } + + Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VMPath $VMPath -Switchname $HydrationSwitchname -TimeZone $TimeZone -DHCPScope $LabConfig.DHCPscope -DHCPScopeState $DHCPScopeState -AdminPassword $LabConfig.AdminPassword $DC=Get-VM -Name $DCName if ($DC -eq $null){ WriteErrorAndExit "DC was not created successfully Press any key to continue ..." From b76567d50c3f9c3b35a00b7828d2b0f1c0f5958e Mon Sep 17 00:00:00 2001 From: Matt McSpirit Date: Thu, 20 Mar 2025 13:23:36 -0700 Subject: [PATCH 3/3] Updating to allow DHCP Scope Active/Inactive --- Scripts/3_Deploy.ps1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Scripts/3_Deploy.ps1 b/Scripts/3_Deploy.ps1 index afcef0b5..21e236a7 100644 --- a/Scripts/3_Deploy.ps1 +++ b/Scripts/3_Deploy.ps1 @@ -947,6 +947,16 @@ If (-not $isAdmin) { $LabConfig.DHCPscope="10.0.0.0" } + if (!$LabConfig.DHCPscopeActive){ + $DHCPScopeState = 'Active' + } + elseif ($LabConfig.DHCPscopeActive -eq $false){ + $DHCPScopeState = 'Inactive' + } + else { + $DHCPScopeState = 'Active' + } + WriteInfoHighlighted "List of variables used" WriteInfo "`t Prefix used in lab is $($labconfig.prefix)" @@ -1287,13 +1297,6 @@ If (-not $isAdmin) { $VMPath="$PSScriptRoot\LAB\" $HydrationSwitchname="DC_HydrationSwitch_$([guid]::NewGuid())" - if ($LabConfig.DHCPscopeActive -eq $false){ - $DHCPScopeState = 'Inctive' - } - else { - $DHCPScopeState = 'Active' - } - Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VMPath $VMPath -Switchname $HydrationSwitchname -TimeZone $TimeZone -DHCPScope $LabConfig.DHCPscope -DHCPScopeState $DHCPScopeState -AdminPassword $LabConfig.AdminPassword $DC=Get-VM -Name $DCName if ($DC -eq $null){