powershelldhcp

Powershell Set-DhcpServerv4Reservation


I was wondering it is possible to use Set-DhcpServerv4Reservation in order to change the IP Address of a reservation. If not, is the only way to do so completely deleting the reservation and then recreating it with the new settings?

Thanks in advance.


Solution

  • You have to first delete the reservation and then re add it using the preferred settings.

    $newip="132.4.5.214"
    $query = Get-DhcpServerv4Reservation -ScopeId $scopeid -ComputerName $serverName | WHERE {$_.IPAddress.IPAddressToString-eq $testip}
            if($query.Name){
                $ip = $query.IPAddress.IPAddressToString
                Remove-DhcpServerv4Reservation -ComputerName $serverName -IPAddress $ip
                Add-DhcpServerv4Reservation -ScopeId $scopeid -ComputerName $serverName-IPAddress $newIP -ClientId $query.ClientId -Name $query.Name
    }