Managing DHCP with PowerShell Part 1

Migrating DHCP Servers & Scopes

In this blog post I’ll discuss the steps for Migrating to a new DHCP Server. This will cover a hub and spoke topology. This process is very well documented however I’ll cover off some real world information and share what I’ve learnt from the experience.

I’d recommend using these documents from Microsoft as a reference point throughout the process so you get the best deployment possible

DHCP Failover Architecture
Understand and Deploy DHCP Failover

Pre-requisites

  1. PowerShell Remoting enabled
  2. RSAT Tools installed. This will enable the PowerShell cmdlets for DHCP.
  3. Add new IP helpers

Be aware that the RSAT Tools for Windows 10 have specific versions based on the existing build. Here’s a page to a number of RSAT Tools based on the version of Windows

Here’s a few articles on getting you started with PowerShell remoting

Enable PowerShell Remoting
Running Remote Commands

Scenario

In this scenario I have an existing DHCP server and I want to migrate the scopes from this server to another server and then set up a hot standby. These steps can be summarized

The 3 servers are as follows:

DHCP1, existing DHCP server
DHCP2, new DHCP server
DHCP3, Failover server

  1. Export DHCP scope(s) from old server
  2. Import DHCP scopes(s) to new server
  3. Deactivate old scope(s) (Old Server)
  4. Activate new scope(s) (New Server)
  5. Decommission old IP helpers

Export existing DHCP scope

  1. Make a connection to your existing DHCP server using PowerShell remoting.
  2. Once you’ve made a connection you can export the scopes using this PowerShell script

<#
Author: <Author Name>
Created: <Date>
Purpose: This script exports DHCP scopes
#>

# Script Variables

# DHCP Server Name – (Change for your environment)
$DHCPServerName = ‘DHCP1.domain.local’
# Path and File name of the DHCP Export (Amend the path and name)
$DHCPFile = C:\Temp\ScopeIDsExport.xml
# DHCP Scopes to Export (change values for the actual scopeIDs in your environment)
$ScopeIDs = @(“10.0.0.0″,”172.16.0.0″,”192.168.0”)

Export-DhcpServer -ComputerName $DHCPServerName -File $DHCPFile -ScopeId $ScopeIDs

You should now have a set of scopes exported that you can use import to your new DHCP Server

Part 2 will look at how to import the scopes to the new DHCP server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s