Scripts

CopyDHCPClients – Copies Microsoft DHCP reservations from one server/scope to another server/scope

Written in 2008 for the Windows versions of the time. Check that the tool or steps still suit your environment before using them.

Prerequisites

  • Microsoft DHCP source and target servers

CopyDHCPClients by Shaun Vermaak copies Microsoft DHCP reservations from one server/scope to another server/scope.

Usage: CopyDHCPClients.exe SOURCESERVER SOURCESCOPE TARGETSERVER TARGETSCOPE

Publishers website: https://www.ittelligence.com
ITtelligence mirror: CopyDHCPClients.zip (9.15 Kb)

How to Use ItLink to this section

It reads the source scope with netsh dhcp server ... dump, takes every Add reservedip line, rewrites it for the target and runs it with netsh.

CopyDHCPClients.exe SOURCESERVER SOURCESCOPE TARGETSERVER TARGETSCOPE
CopyDHCPClients.exe 192.168.1.5 192.168.1.0 192.168.2.5 192.168.2.0

Parameter

Meaning

SOURCESERVER

DHCP server to read reservations from.

SOURCESCOPE

Scope on the source server, for example 192.168.1.0.

TARGETSERVER

DHCP server to create the reservations on.

TARGETSCOPE

Scope on the target server.

Each reservation keeps its last octet but takes the first three octets of the target scope, so 192.168.1.50 becomes 192.168.2.50. For every reservation it prints the netsh command it ran followed by netsh's exit code (0 means success). Run it where netsh has the DHCP context and with rights on both servers. It writes a temporary Dump.txt in the current folder, so that folder must be writable.

Note: the server and scope are swapped by plain text replacement, so give SOURCESERVER exactly as it appears in the dump output (name or IP). If it does not match, the rewritten lines still point at the source server.

Posted on

Tagged DHCP

No comments yet

Comments are moderated and appear once approved.