DHCP – Exporting and Importing scopes explained

So here is the scenario facing you.

You currently have multiple on-premises DHCP servers servicing your users at various locations and they are on old out of support operation systems.

What do you do to update your DHCP environment?

Firstly, provision two new DHCP servers on the latest operation system and preferably virtually to make supporting and maintaining the servers easier.

Secondly, when the scopes were originally defined, was it on a much earlier version of the Windows OS as in this example?

If so, perhaps it’s worth looking at the scope configuration, is it still fit for purpose, do the sites or locations still exist or have as many users requiring an IP lease?

So what can you do to check, well there is the usual checks on IP ranges, exclusions, reservations, scope options and such, and pruning any old configuration.

Have any new DHCP features become available? Yes they have and examples of this are active/active scopes for resilience, and the ability to back-up the configuration via the GUI and via PowerShell.

PowerShell cmdlets exist which can export and import active lease information, smoothing the migration process.

So what do these PowerShell cmdlets look like?

Exporting a DHCP scope:

Export-DhcpServer -ComputerName <servername> -ScopeId <IP subnet> -Leases – File .\<servername>_<scopename>.xml

Where ComputerName is the DHCP server machine name that you want to export a scope from.

ScopeId is the actual DHCP scope you want to export, especially if there are multiple scopes on the server you are migrating, e.g. 10.x.x.x

Finally, where are you putting the exported scope file in xml format and what is the file being called.

So you have exported the scope, what next?

Well firstly you need to copy that xml file onto the new DHCP server where you want to import it.

Then what?

Importing a DHCP scope:

Import-DhcpServer -Leases -File .\<servername>_<scopename>.xml -BackupPath “C:\xxxx” -Verbose

Where the filename needs to match the name entered in the export command above and the Backup path needs to match where you have put that file.

Once you press enter on this command you will be asked to confirm that this is the scope to be imported, default is Yes.

So what are the next steps then.

I will cover this topic in a future blog

About the author