27 lines
902 B
PowerShell
27 lines
902 B
PowerShell
#Requires -Modules 'DhcpServer'
|
|
Param(
|
|
[Parameter(Mandatory)]
|
|
[hashtable]$Parameter
|
|
)
|
|
|
|
# Configure DHCP (if and only if this server is not already an authorized DHCP server)
|
|
If ((Get-DHCPServerInDC).IPAddress -NotContains $Parameter['guestinfo.ipaddress']) {
|
|
# Add DHCP security groups
|
|
& netsh dhcp add securitygroups
|
|
|
|
# Authorize DHCP server
|
|
$AddDhcpServerInDCSplat = @{
|
|
DnsName = "$($Parameter['guestinfo.hostname']).$($Parameter['addsconfig.domainname'])"
|
|
IPAddress = $($Parameter['guestinfo.ipaddress'])
|
|
Confirm = $False
|
|
}
|
|
Add-DhcpServerInDC @AddDhcpServerInDCSplat
|
|
|
|
# Notify Server Manager post-install configuration has completed
|
|
$SetItemPropertySplat = @{
|
|
Path = 'HKLM:\SOFTWARE\Microsoft\ServerManager\Roles\12'
|
|
Name = 'ConfigurationState'
|
|
Value = 2
|
|
}
|
|
Set-ItemProperty @SetItemPropertySplat
|
|
} |