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