Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Scripts/0_DCHydrate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ function Hydrate-DC {
[parameter(Mandatory=$true)]
[string]$DhcpScope,

[parameter(Mandatory=$true)]
[string]$DhcpScopeState,

[parameter(Mandatory=$true)]
[string]$AdminPassword)

Expand Down Expand Up @@ -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"
}
Expand Down
12 changes: 1 addition & 11 deletions Scripts/2_CreateParentDisks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ..."
Expand Down
19 changes: 10 additions & 9 deletions Scripts/3_Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ..."
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Scripts/LabConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down