---
title: "Migrate DHCP Without Losing Leases with Export-DhcpServer"
description: "Move a DHCP server with Export-DhcpServer and Import-DhcpServer, keeping leases intact, then authorize the new server in Active Directory."
canonical: "https://adamtheautomator.com/migrate-dhcp-server-export-dhcpserver/"
---

# Migrate DHCP Without Losing Leases with Export-DhcpServer

> Move a DHCP server with Export-DhcpServer and Import-DhcpServer, keeping leases intact, then authorize the new server in Active Directory.

Source: https://adamtheautomator.com/migrate-dhcp-server-export-dhcpserver/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Migrate DHCP Without Losing Leases with Export-DhcpServer](https://adamtheautomator.com/wp-content/uploads/publisher/3f95d9c85b2b813190efe4fbf5ba49f1/01cf2782293526c501009180bd8555b6e73ab2cef8c62a48d76f7970916c3080.jpg)

# Migrate DHCP Without Losing Leases with Export-DhcpServer

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)23 October 20263 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[DHCP](/tag/dhcp/)[Microsoft Windows Server](/tag/microsoft-windows-server/)[PowerShell](/tag/powershell/)[Active Directory](/tag/active-directory/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Install the Role on the New Server](#install-the-role-on-the-new-server)
*   [Run Export-DhcpServer, Then Deactivate the Old Scopes](#run-export-dhcpserver-then-deactivate-the-old-scopes)
*   [Copy the File and Run Import-DhcpServer](#copy-the-file-and-run-import-dhcpserver)
*   [Handle Scopes That Already Exist](#handle-scopes-that-already-exist)
*   [Roll Back a Bad Import](#roll-back-a-bad-import)
*   [Verify the Import](#verify-the-import)
*   [Authorize the New Server](#authorize-the-new-server)
*   [Retire the Old Server](#retire-the-old-server)

Picture two laptops holding the same IP address the morning after a DHCP cutover. The new server never learned which addresses the old one had leased. Block that conflict with one switch: run [`Export-DhcpServer`](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/export-dhcpserver?view=windowsserver2025-ps) with `-Leases`, then pass `-Leases` again to [`Import-DhcpServer`](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/import-dhcpserver?view=windowsserver2025-ps).

Then hold the new server back. Leave it unauthorized in Active Directory until its scope and lease counts match the old server’s.

## Prerequisites

If you want to follow along, you need:

*   Local administrator rights on both servers, which [Microsoft’s DHCP migration guide](https://learn.microsoft.com/en-us/windows-server/networking/technologies/dhcp/migrate-dhcp-server) lists for installing and managing the role.
    
*   Domain administrative rights to authorize the new server, per the same guide; in a child domain, [authorization needs Enterprise Admin or delegated rights](https://rakhesh.com/windows/authorizing-a-dhcp-server-in-a-child-domain-requires-enterprise-admin-rights-or-a-delegation/) on the NetServices container, so sort this out before cutover day.
    
*   A new Windows Server with a static IP in the old server’s domain, while the old server keeps running until cutover.
    
*   A standalone old server. For a failover pair, use Microsoft’s [failover migration guide](https://learn.microsoft.com/en-us/windows-server/networking/technologies/dhcp/migrate-existing-dhcp-failover), which removes the relationship first and imports only server-level settings.
    

The syntax below follows the Windows Server 2025 version of each cmdlet’s reference page.

## Install the Role on the New Server

On the new server, install the role and its PowerShell module:

```powershell
Install-WindowsFeature -Name DHCP -IncludeManagementTools
```

The [Install-WindowsFeature](https://learn.microsoft.com/en-us/powershell/module/servermanager/install-windowsfeature) switch `-IncludeManagementTools` adds the DHCP console and the DhcpServer module that holds the export and import cmdlets. Leave the server unauthorized for now. Two servers must never answer the same client.

Next, create the folder that `-BackupPath` will use. Creating it also creates the `C:\dhcp` parent where the export file lands:

```powershell
New-Item -ItemType Directory -Path C:\dhcp\backup -Force
```

## Run Export-DhcpServer, Then Deactivate the Old Scopes

The diagram below highlights the gap between export and deactivation, where leases can go missing.

![DHCP migration sequence](https://adamtheautomator.com/wp-content/uploads/publisher/22695d4987a4007f043c7ed00810981634b0792fb7440dc7230ef52d666e625c.png)

On the old server, create a working folder and export everything, leases included:

```powershell
New-Item -ItemType Directory -Path C:\dhcp -Force
Export-DhcpServer -File C:\dhcp\dhcp.xml -Leases
```

`-File` is the only mandatory parameter. Add `-Force` to overwrite an existing file. Without `-Leases`, the file holds configuration only. The new server then has no record of addresses clients hold, which lets it lease one to a second client.

Right after the export, deactivate every scope on the old server in the same console:

```powershell
Get-DhcpServerv4Scope | Set-DhcpServerv4Scope -State InActive
```

[Set-DhcpServerv4Scope](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/set-dhcpserverv4scope) accepts `Active` and `InActive` for `-State`. Any lease the old server grants between the export and this command is missing from the XML.

* * *

_**Warning: Deactivated scopes stop answering new lease and renewal requests, so clients get no answer from either server until you authorize the new one. Deactivate only when you can finish every step through authorization within minutes.**_

* * *

## Copy the File and Run Import-DhcpServer

Copy the file to the new server:

```powershell
Copy-Item C:\dhcp\dhcp.xml \\new-dhcp\C$\dhcp\
```

On the new server, import `dhcp.xml` with a backup path:

```powershell
Import-DhcpServer -File C:\dhcp\dhcp.xml -BackupPath C:\dhcp\backup -Leases -Verbose
```

The Import-DhcpServer reference describes `-BackupPath` as “the path where DHCP server database is backed up before it makes any configuration changes as part of the import operation.”

The path is mandatory even on an empty server. `-Leases` has to appear on the import too, because it is the switch that loads the lease data from the file.

### Handle Scopes That Already Exist

If a scope in the file exists on the new server, `Import-DhcpServer` shows a warning and moves to the next scope. Add `-ScopeOverwrite` only when you want the existing scope deleted and recreated from the file.

### Roll Back a Bad Import

If the counts in the next section come up short, [Restore-DhcpServer](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/restore-dhcpserver) rolls the new server back to the database `-BackupPath` saved before the import:

```powershell
Restore-DhcpServer -Path C:\dhcp\backup
```

## Verify the Import

List the scopes and confirm each `State` matches what the old server showed before you deactivated it:

```powershell
Get-DhcpServerv4Scope | Select-Object ScopeId, Name, State
```

One user on [Microsoft Q&A](https://learn.microsoft.com/en-us/answers/questions/2116014/windows-dhcp-server-xml-import-file-import-issue-f) reported a seven-scope file that imported four scopes with no error, with no confirmed cause. Compare scope counts on both servers:

```powershell
(Get-DhcpServerv4Scope -ComputerName old-dhcp.contoso.com).Count
(Get-DhcpServerv4Scope).Count
```

Spot-check [one scope’s leases](https://adamtheautomator.com/dhcp-leases-reservations-powershell/) on both servers with [Get-DhcpServerv4Lease](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/get-dhcpserverv4lease), as the capture below shows:

```powershell
Get-DhcpServerv4Lease -ComputerName old-dhcp.contoso.com -ScopeId 10.0.0.0 | Measure-Object
Get-DhcpServerv4Lease -ScopeId 10.0.0.0 | Measure-Object
```

![Scope and lease counts](https://adamtheautomator.com/wp-content/uploads/publisher/9a74dbd5e225819a4276f4e1e04ad3a2aa48fd0432c7aa5fc62d0e987b549e3d.png)

## Authorize the New Server

When the counts match, authorize the server. The [Add-DhcpServerInDC reference](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/add-dhcpserverindc?view=windowsserver2025-ps) states: “A DHCP server service that runs on a domain joined computer must be authorized in Active Directory so that it can start leasing IP addresses on the network.”

* * *

_**Key Insight: If the new server has a different IP address than the old one, update the DHCP relay agents (the router setting that forwards client broadcasts, often called an IP helper) before you authorize the server and test clients on other subnets.**_

* * *

Then register the new server:

```powershell
Add-DhcpServerInDC -DnsName new-dhcp.contoso.com
```

Confirm the registration with `Get-DhcpServerInDC`, then [run `ipconfig /renew`](https://adamtheautomator.com/ipconfig-commands/) on a client and look for its lease on the new server.

## Retire the Old Server

Microsoft’s migration guide says a client renewing against the old IP fails once, then rediscovers the new server. Once you have watched renewals succeed, remove the old server’s authorization with [Remove-DhcpServerInDC](https://learn.microsoft.com/en-us/powershell/module/dhcpserver/remove-dhcpserverindc):

```powershell
Remove-DhcpServerInDC -DnsName old-dhcp.contoso.com
```

Keep _C:\\dhcp\\dhcp.xml_ and the old server until clients on every subnet renew against the new one. Both give you a way back.

Before authorization, undo a bad import with `Restore-DhcpServer -Path C:\dhcp\backup` on the new server, then import again.

After cutover, fall back to the old server. Remove the new server’s authorization with `Remove-DhcpServerInDC`, reactivate the old scopes with `Set-DhcpServerv4Scope -State Active`, and re-authorize the old server with `Add-DhcpServerInDC`.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fmigrate-dhcp-server-export-dhcpserver%2F&text=Migrate%20DHCP%20Without%20Losing%20Leases%20with%20Export-DhcpServer)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fmigrate-dhcp-server-export-dhcpserver%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fmigrate-dhcp-server-export-dhcpserver%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/publisher/3f95d9c85b2b81e69730da4c690758c2/4afeea42b7f854d23285b281664351779f042510f1e3a1d766d02cfa39b711a8.jpg)

### [Find and Disable Every Inactive AD Computer with PowerShell](/find-inactive-computers-active-directory/)

Find inactive computer accounts in Active Directory with Search-ADAccount, then disable and quarantine them with PowerShell in steps you can undo.

![](https://adamtheautomator.com/wp-content/uploads/publisher/3ec5d9c85b2b8183bec6e5cc0f0356c5/a323a4d03629188de1d5ed18ca60a64a65f94bef73d5390488bde5511859fa05.webp)

### [AZ-800 vs. AZ-802: Avoid the Wrong Windows Server Exam](/az-800-vs-az-802/)

See what the AZ-800 retirement means for your Windows Server certification path and how to re-weight your study plan around the current AZ-802 exam.

![](https://adamtheautomator.com/wp-content/uploads/publisher/3f95d9c85b2b817aab5dca59f1ca0e14/38378bffb6e067df12a1bd90a3921833213a6e328f7d3baabd1fae698d38ddfd.jpg)

### [Fix Kerberos Clock Skew Logon Failures Using w32tm](/fix-kerberos-clock-skew-w32tm/)

Fix Kerberos clock skew logon failures by checking w32tm sources, pointing the PDC emulator at NTP, and resyncing drifted clients.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
