Need an easy way to move reserved IPs in DHCP?

What does this script do?

Okay, let’s say you have IPs in the DHCP reservation which you want to move to a new IP address then this Powershell script is for you. If you do it manually you will need to delete the reservation and create a new reservation with the mac address and new IP address.

This script only requires the old IP address and the new IP.

Make sure you update the DHCP server name.

Here it is:

Write-host '------------------------'
Write-host '--   DHCP IP Mover    --'
Write-host '------------------------'
#IP to Change
#$ipaddress = '’

#New IP
#$newip = '’

$ipaddress = Read-Host -Prompt 'Old IP: '

$newip = Read-Host -Prompt 'New IP: '

#DHCP Server
$dhcpserver = 'server01'

#Current Reservation Description
$description = Get-DhcpServerv4Scope -ComputerName $dhcpserver | Get-DhcpServerv4Reservation -ComputerName $dhcpserver | where {$_.ipaddress -eq $ipaddress} | select -expandproperty description

#Current Reservation Scope ID
$scopeid = Get-DhcpServerv4Scope -ComputerName $dhcpserver | Get-DhcpServerv4Reservation -ComputerName $dhcpserver | where {$_.ipaddress -eq $ipaddress} | foreach {$_.scopeid.ipaddresstostring}

#Current Reservation MAC
$mac = Get-DhcpServerv4Scope -ComputerName $dhcpserver| Get-DhcpServerv4Reservation -ComputerName $dhcpserver | where {$_.ipaddress -eq $ipaddress} | select -expandproperty clientid

#Current Reservation Name
$name = Get-DhcpServerv4Scope -ComputerName $dhcpserver| Get-DhcpServerv4Reservation -ComputerName $dhcpserver | where {$_.ipaddress -eq $ipaddress} | select -expandproperty name

#Delete Current Reservation
Remove-DhcpServerv4Reservation -ComputerName $dhcpserver -IP $ipaddress

#Recreate Reservation With New IP
Add-DhcpServerv4Reservation -ComputerName $dhcpserver -Name $name -ScopeId $scopeid -IPAddress $newip -ClientId $mac -Description $description

By the way have you seen the RAVPower FileHub? It's a travel Router with wifi AC750 300Mbps Wi-Fi on 2.4Ghz or 433 Mbps on 5Ghz. It includes an SD Card Reader, 6700mAh Battery and can connect an SSD hd. Make this a portable NAS to store your pics and videos or upload your SD card pics/videos to a SSD hd. This is a bargain for under $60. (Amazon USA Link)

Did our article help you? Here are some ways you can help us.

Have a look at our IT Tech Tool Kit List, need ideas on what to buy? I have listed my top 29 tools here.

Buy me a coffeeBuy me a coffee

No votes yet.
Please wait...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.