I’m needing to migrate from Windows Server 2012 R2 to 2019. This is fairly straight forward with PowerShell. This guide assumes you have an existing 2012R2 server with DHCP role and a clean 2019 server fully patched.
Before you begin document your current system such as current hostname / and IP Address. I’m going to be reusing the same hostname and IP.
- Lower DHCP lease times to ~30mins at least 24hrs before swapping servers. This would ultimately depend on what your current lease times are. Ours are 24hrs so I’m going to change them to 30mins. Once we authorize the new server, I’ll reset them to 24hrs.
- On the the 2012R2 server open a PowerShell instance (run as admin)
- Run the following command:
Export-DhcpServer -File C:\DHCPdata.xml -Leases -Force -ComputerName OLDSERVERNAME –Verbose
Don’t forget to change the -ComputerName matching your server 2012R2 hostname.
4) Save the file created in the root of C:\ to your new Server 2019 Server.
5) Install the DHCP Server Role via server manager.
6) Let’s import our previous config. Open Powershell (run as admin) and put in:
Import-DhcpServer -File C:\DHCPdata.xml -BackupPath C:\DHCP\ -Leases -ScopeOverwrite -Force -ComputerName NEWSERVERNAME –Verbose
7) If everything looks good, lets authorize the new server! Right click your DHCP server and select Authorize.
You should have some green checkmarks if its activated!
8) Deauthorize your old server following the same steps in the last step but on the server to decommission. Instead of authorize, it will say deauthorize.
9) It can take a few mins for the status to update.
If it’s not updating here are some commands to use. Run these on your DHCP servers.
Show active DHCP servers
netsh dhcp show server
Remove a currently registered DHCP server (replace hostname and IP with your old server)
netsh dhcp delete server dhcp01.contoso.com 10.0.1.2
Authorize a DHCP server
netsh dhcp add server dhcp02.contoso.com 10.254.1.2
10) Verify you only have 1 authorized DHCP server
11) Increase the lease times from 30mins back to your original times per scope.