Skip to content

Commit e2cb23b

Browse files
authored
Merge pull request #624 from microsoft/dev
Dev
2 parents 2a93484 + 4e4843f commit e2cb23b

File tree

4 files changed

+13
-25
lines changed

4 files changed

+13
-25
lines changed

Scripts/0_DCHydrate.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ function Hydrate-DC {
9696
[parameter(Mandatory=$true)]
9797
[string]$DhcpScope,
9898

99-
[parameter(Mandatory=$true)]
100-
[string]$DhcpScopeState,
101-
10299
[parameter(Mandatory=$true)]
103100
[string]$AdminPassword)
104101

@@ -400,7 +397,7 @@ function Hydrate-DC {
400397
Name = 'ManagementScope'
401398
SubnetMask = '255.255.255.0'
402399
LeaseDuration = ((New-TimeSpan -Hours 8).ToString())
403-
State = $DHCPScopeState
400+
State = 'Active'
404401
AddressFamily = 'IPv4'
405402
DependsOn = "[Service]DHCPServer"
406403
}

Scripts/2_CreateParentDisks.ps1

+1-11
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ If (-not $isAdmin) {
6464
$LabConfig.DHCPscope="10.0.0.0"
6565
}
6666

67-
if (!$LabConfig.DHCPscopeActive){
68-
$DHCPScopeState = 'Active'
69-
}
70-
elseif ($LabConfig.DHCPscopeActive -eq $false){
71-
$DHCPScopeState = 'Inactive'
72-
}
73-
else {
74-
$DHCPScopeState = 'Active'
75-
}
76-
7767
#create some built-in variables
7868
$DN=$null
7969
$LabConfig.DomainName.Split(".") | ForEach-Object {
@@ -534,7 +524,7 @@ if (-not $DCFilesExists){
534524
#region create DC if it does not exist
535525
if (-not $DCFilesExists) {
536526
if (-not $LabConfig.NoDehydrateDC){
537-
Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VmPath $VmPath -SwitchName $Switchname -TimeZone $TimeZone -DhcpScope $LabConfig.DHCPscope -DHCPScopeState $DHCPScopeState -AdminPassword $AdminPassword
527+
Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VmPath $VmPath -SwitchName $Switchname -TimeZone $TimeZone -DhcpScope $LabConfig.DHCPscope -AdminPassword $AdminPassword
538528
$DC=Get-VM -Name $DCName
539529
if ($DC -eq $null){
540530
WriteErrorAndExit "DC was not created successfully Press any key to continue ..."

Scripts/3_Deploy.ps1

+10-9
Original file line numberDiff line numberDiff line change
@@ -947,14 +947,8 @@ If (-not $isAdmin) {
947947
$LabConfig.DHCPscope="10.0.0.0"
948948
}
949949

950-
if (!$LabConfig.DHCPscopeActive){
951-
$DHCPScopeState = 'Active'
952-
}
953-
elseif ($LabConfig.DHCPscopeActive -eq $false){
954-
$DHCPScopeState = 'Inactive'
955-
}
956-
else {
957-
$DHCPScopeState = 'Active'
950+
if (!$LabConfig.DHCPscopeState){
951+
$LabConfig.DHCPscopeState = 'Active'
958952
}
959953

960954
WriteInfoHighlighted "List of variables used"
@@ -1297,7 +1291,7 @@ If (-not $isAdmin) {
12971291
$VMPath="$PSScriptRoot\LAB\"
12981292
$HydrationSwitchname="DC_HydrationSwitch_$([guid]::NewGuid())"
12991293

1300-
Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VMPath $VMPath -Switchname $HydrationSwitchname -TimeZone $TimeZone -DHCPScope $LabConfig.DHCPscope -DHCPScopeState $DHCPScopeState -AdminPassword $LabConfig.AdminPassword
1294+
Hydrate-DC -DCName $DCName -VhdPath $vhdpath -VMPath $VMPath -Switchname $HydrationSwitchname -TimeZone $TimeZone -DHCPScope $LabConfig.DHCPscope -AdminPassword $LabConfig.AdminPassword
13011295
$DC=Get-VM -Name $DCName
13021296
if ($DC -eq $null){
13031297
WriteErrorAndExit "DC was not created successfully Press any key to continue ..."
@@ -1484,6 +1478,13 @@ If (-not $isAdmin) {
14841478
Get-DhcpServerInDC | Remove-DHCPServerInDC
14851479
Add-DhcpServerInDC -DnsName "DC.$($Labconfig.DomainName)" -IPAddress 10.0.0.1
14861480
}
1481+
#configure DHCP Management Scope if configured in LabConfig file
1482+
if ($LabConfig.DHCPscopeState -eq 'Inactive') {
1483+
WriteInfo "`t Deactivating DHCP Management Scope based on LabConfig entry"
1484+
Invoke-Command -VMGuid $DC.id -Credential $cred -ScriptBlock {
1485+
Get-DhcpServerv4Scope | Set-DhcpServerv4Scope -State Inactive
1486+
}
1487+
}
14871488
}
14881489

14891490
#configure NAT on DC

Scripts/LabConfig.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $LabConfig=@{AllowedVLANs="1-10,711-719" ; DomainAdminName='LabAdmin'; AdminPass
3737
EnableGuestServiceInterface=$false; # (Optional) If True, then Guest Services integration component will be enabled on all VMs.
3838
DCVMProcessorCount=2; # (Optional) 2 is default. If specified more/less, processorcount will be modified.
3939
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
40-
DHCPscopeActive=$true; # (Optional) If set to $false, DHCP Scope is created, but set to 'Inactive'
40+
DHCPscopeState="Active"; # (Optional) If set to "Inactive", DHCP Scope is created, but set to 'Inactive'. If nothing specified, default is 'Active'
4141
DCVMVersion="9.0"; # (Optional) Latest is used if nothing is specified. Make sure you use values like "8.0","8.3","9.0"
4242
TelemetryLevel=""; # (Optional) If configured, script will stop prompting you for telemetry. Values are "None","Basic","Full"
4343
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

0 commit comments

Comments
 (0)