54 lines
1.7 KiB
PowerShell
54 lines
1.7 KiB
PowerShell
#Requires -Modules 'DhcpServer'
|
|
Param(
|
|
[Parameter(Mandatory)]
|
|
[hashtable]$Parameter
|
|
)
|
|
|
|
# Only executed on secondary or standalone Domain Controller
|
|
If (@('secondary','standalone') -contains $Parameter['deployment.type']) {
|
|
$AddDhcpServerv4ScopeSplat = @{
|
|
Name = 'Default DHCP scope'
|
|
StartRange = [ipaddress]$Parameter['dhcpconfig.startip']
|
|
EndRange = [ipaddress]$Parameter['dhcpconfig.endip']
|
|
SubnetMask = [ipaddress]$Parameter['dhcpconfig.subnetmask']
|
|
LeaseDuration = [timespan]$Parameter['dhcpconfig.leaseduration']
|
|
State = 'Active'
|
|
PassThru = $True
|
|
Confirm = $False
|
|
}
|
|
$DhcpScope = Add-DhcpServerv4Scope @AddDhcpServerv4ScopeSplat
|
|
|
|
$ScopeOptions = @(
|
|
@{
|
|
# 003 Router
|
|
OptionId = 3
|
|
Value = $Parameter['dhcpconfig.gateway']
|
|
},
|
|
@{
|
|
# 004 Time Server
|
|
OptionId = 4
|
|
Value = (Resolve-DnsName -Name $Parameter['addsconfig.domainname']).IPAddress
|
|
},
|
|
@{
|
|
# 006 DNS Server
|
|
OptionId = 6
|
|
Value = (Resolve-DnsName -Name $Parameter['addsconfig.domainname']).IPAddress
|
|
},
|
|
@{
|
|
# 015 DNS Domain Name
|
|
OptionId = 15
|
|
Value = $Parameter['addsconfig.domainname']
|
|
}
|
|
)
|
|
|
|
ForEach ($Option in $ScopeOptions) {
|
|
$SetDhcpServerv4OptionValueSplat = @{
|
|
ScopeId = $DhcpScope.ScopeId
|
|
OptionId = $Option.OptionId
|
|
Value = $Option.Value
|
|
Force = $True
|
|
Confirm = $False
|
|
}
|
|
Set-DhcpServerv4OptionValue @SetDhcpServerv4OptionValueSplat
|
|
}
|
|
} |