In this article, we will look at how to export and import all settings from one DHCP Server to another. This method is used when we need to migrate an older DHCP Server (eg Windows Server 2008 R2) to a new server (eg Windows Server 2016).
The export and import process can be done either through the command line using the Netsh tool or through the PowerShell using the corresponding cmdlets that we will see below. Microsoft, apparently, suggests using PowerShell in these cases as Netsh is deprecated.
Additionally, if you use the DHCP Failover and DHCP Policies features, then PowerShell is a one-way street because the Netsh command does not support extracting these objects.
Export and Import of DHCP settings using Netsh
Log in to the DHCP Server you are about to shut down, open the command line with administrator privileges, and type the following command.
netsh dhcp server export C:\DHCP-Config.txt all
Obviously, the .txt file can be named as you want as well as saving it to a folder of your choice. Just make sure to create it before it as netsh does not automatically create it.
Then connect to the new DHCP Server and copy the .txt file to the disk. Reopen the command line with administrator privileges and type the following command.
netsh dhcp server import C:\DHCP-Config.txt all
Obviously, you will need to change the location of the file to suit your case.
Export and Import DHCP settings using PowerShell
Log in to the DHCP Server you are about to remove, open PowerShell with Administrator privileges, and type the following command to export all the DHCP Server settings.
Export-DhcpServer -ComputerName DC01 -File "C:\DHCP-Config.xml" -Force
Then connect to the new DHCP Server and copy the .xml file to the disk. Open PowerShell with Administrator privileges and type the following command to import the settings from the file.
Import-DhcpServer -ComputerName DC02 -File "C:\DHCP-Config.xml -Force
In both cases, you can skip the -Force parameter to confirm your action in the corresponding message that appears.
As I mentioned above, only the export and import methods exist in this article. If you are going to migrate the DHCP server from one server to another, it is a good idea to read all the steps you will need to follow to successfully complete it.