Install DHCP Server Role Using PowerShell
This article has not been completed yet. However, it may already contain helpful information and therefore it has been published at this stage.
I recently had to replace the DHCP service at one of my customers. The customer was still using a solution implemented on a old firewall. Enclosed is the initial situation (see screen below).
# Installing the server role
Install-WindowsFeature DHCP -IncludeManagementTools
# Create DHCP security groups for authorization
Netsh DHCP Add SecurityGroups
# DHCP - Server Restart
Restart-Service DHCPServer
# Authorize DHCP server
Add-DHCPServerInDC
# Showing available Net-Adapter
Get-NetAdapter
# DHCP Netadapter - Binding
Set-DHCPServerv4Binding -BindingState $True -InterfaceAlias "Ethernet"
# Creating a DHCP range
Add-DhcpServerv4Scope -Name <Name> -StartRange <IP> -EndRange <IP> -SubnetMask <SubnetMask>
# Disable Scope
Set-DHCPServerv4Scope -ScopeId <IP> -state Inactive
# Enabling Continuous Dynamic DNS Updates
Set-DhcpServerv4DnsSetting -ComputerName "<Name>" -DynamicUpdates
"Always" -DeleteDnsRRonLeaseExpiry $True
Set-DHCPServerv4OptionValue -OptionID 3 -Value <IP> -ScopeID <IP> -ComputerName <FQDN>
Set-DhcpServerv4OptionValue -DnsDomain <Domain> -DnsServer <IP>
# DHCP-Server Config Backup
Backup-DHCPServer -path C:\BackupDHCP
# Restore DHCP-Server Config Backup
Restore-DHCPServer -ComputerName <Name> -Path C:\BackupDHCP
# DHCP - Server Restart
Restart-Service DHCPServer
# Finishing the DHCP Setup
Set-ItemProperty –Path
registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\12 –Name
ConfigurationState -Value 2