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.
HI, I was trying to figure out how to export and import just the filter list into a DHCP server used as a failover, but I’m coming up dry. Do you have any pointers?
Hi, I’d like to export from a 2016 server to 2012. I’m getting an error that version 6.3 is not compatible with file version 10.0. Any ideas?
Just had the same problem, If you still interested in answer, Just edit the XML file and change the MajorVersion to 6 from 10 and MinorVersion to 3
Thanks B saved my life with that one
Powershell need backup folder when importing so the command on this page is not complete.
It should be:
Import-DhcpServer -ComputerName -File C:\DHCP-Config.xml -BackupPath -Force
Backup folder is that folder, which is in system32\DHCP\Backup
Thanks for this has saved me a lot of time
Simple neat and clean
Working like a charm