diff --git a/Scripts/0_DCHydrate.ps1 b/Scripts/0_DCHydrate.ps1 index e59a9f2e..2d755fd7 100644 --- a/Scripts/0_DCHydrate.ps1 +++ b/Scripts/0_DCHydrate.ps1 @@ -96,9 +96,6 @@ function Hydrate-DC { [parameter(Mandatory=$true)] [string]$DhcpScope, - [parameter(Mandatory=$true)] - [string]$DhcpScopeState, - [parameter(Mandatory=$true)] [string]$AdminPassword) @@ -400,7 +397,7 @@ function Hydrate-DC { Name = 'ManagementScope' SubnetMask = '255.255.255.0' LeaseDuration = ((New-TimeSpan -Hours 8).ToString()) - State = $DHCPScopeState + State = 'Active' AddressFamily = 'IPv4' DependsOn = "[Service]DHCPServer" } diff --git a/Scripts/2_CreateParentDisks.ps1 b/Scripts/2_CreateParentDisks.ps1 index 2391fb8e..f6f77e3b 100644 --- a/Scripts/2_CreateParentDisks.ps1 +++ b/Scripts/2_CreateParentDisks.ps1 @@ -64,16 +64,6 @@ If (-not $isAdmin) { $LabConfig.DHCPscope="10.0.0.0" } - if (!$LabConfig.DHCPscopeActive){ - $DHCPScopeState = 'Active' - } - elseif ($LabConfig.DHCPscopeActive -eq $false){ - $DHCPScopeState = 'Inactive' - } - else { - $DHCPScopeState = 'Active' - } - #create some built-in variables $DN=$null $LabConfig.DomainName.Split(".") | ForEach-Object { @@ -534,7 +524,7 @@ if (-not $DCFilesExists){ #region create DC if it does not exist if (-not $DCFilesExists) { if (-not $LabConfig.NoDehydrateDC){ - Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VmPath $VmPath -SwitchName $Switchname -TimeZone $TimeZone -DhcpScope $LabConfig.DHCPscope -DHCPScopeState $DHCPScopeState -AdminPassword $AdminPassword + Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VmPath $VmPath -SwitchName $Switchname -TimeZone $TimeZone -DhcpScope $LabConfig.DHCPscope -AdminPassword $AdminPassword $DC=Get-VM -Name $DCName if ($DC -eq $null){ WriteErrorAndExit "DC was not created successfully Press any key to continue ..." diff --git a/Scripts/3_Deploy.ps1 b/Scripts/3_Deploy.ps1 index 21e236a7..1400849a 100644 --- a/Scripts/3_Deploy.ps1 +++ b/Scripts/3_Deploy.ps1 @@ -947,14 +947,8 @@ If (-not $isAdmin) { $LabConfig.DHCPscope="10.0.0.0" } - if (!$LabConfig.DHCPscopeActive){ - $DHCPScopeState = 'Active' - } - elseif ($LabConfig.DHCPscopeActive -eq $false){ - $DHCPScopeState = 'Inactive' - } - else { - $DHCPScopeState = 'Active' + if (!$LabConfig.DHCPscopeState){ + $LabConfig.DHCPscopeState = 'Active' } WriteInfoHighlighted "List of variables used" @@ -1297,7 +1291,7 @@ 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 -DHCPScopeState $DHCPScopeState -AdminPassword $LabConfig.AdminPassword + Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VMPath $VMPath -Switchname $HydrationSwitchname -TimeZone $TimeZone -DHCPScope $LabConfig.DHCPscope -AdminPassword $LabConfig.AdminPassword $DC=Get-VM -Name $DCName if ($DC -eq $null){ WriteErrorAndExit "DC was not created successfully Press any key to continue ..." @@ -1484,6 +1478,13 @@ If (-not $isAdmin) { Get-DhcpServerInDC | Remove-DHCPServerInDC Add-DhcpServerInDC -DnsName "DC.$($Labconfig.DomainName)" -IPAddress 10.0.0.1 } + #configure DHCP Management Scope if configured in LabConfig file + if ($LabConfig.DHCPscopeState -eq 'Inactive') { + WriteInfo "`t Deactivating DHCP Management Scope based on LabConfig entry" + Invoke-Command -VMGuid $DC.id -Credential $cred -ScriptBlock { + Get-DhcpServerv4Scope | Set-DhcpServerv4Scope -State Inactive + } + } } #configure NAT on DC diff --git a/Scripts/LabConfig.ps1 b/Scripts/LabConfig.ps1 index 825d7829..1f696afd 100644 --- a/Scripts/LabConfig.ps1 +++ b/Scripts/LabConfig.ps1 @@ -37,7 +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' + DHCPscopeState="Active"; # (Optional) If set to "Inactive", DHCP Scope is created, but set to 'Inactive'. If nothing specified, default is 'Active' 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