Unable to add DHCP v4 leases using powershell command

Surya Shetty 1 Reputation point
2022-08-04T06:20:52.177+00:00

I am using the windows server of the 2016 version running the DHCP instance on it, for testing, I am trying to add, and delete an active lease using the PowerShell command it worked fine for the first trial but after the leases expiry time, I am unable to add a new lease with the new lease expiry time.

The output of the command showing the previous lease added with the state as expired
S C:\Users\Administrator> Get-DhcpServerv4Lease -IPAddress 14.0.0.2

IPAddress ScopeId ClientId HostName AddressState LeaseExpiryTime


14.0.0.2 14.0.0.0 42-2e-7c-b0-a7-c8 Expired 8/4/2022 1:38:13 AM

Trying to add new lease with a new expiry time

PS C:\Users\Administrator>

S C:\Users\Administrator> Add-DhcpServerv4Lease -IPAddress 14.0.0.2 -ScopeId 14.0.0.0 -ClientId 42-2b-7d-b0-a7-c8 -LeaseExpiryTime "2022-08-09 23:38:13" -HostName "phone2.test.com"
Add-DhcpServerv4Lease : Failed to add IP address lease for 14.0.0.2 on server WIN-8S0KSAF0ULF.
At line:1 char:1

  • Add-DhcpServerv4Lease -IPAddress 14.0.0.2 -ScopeId 14.0.0.0 -ClientId ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ResourceExists: (14.0.0.2:root/Microsoft/...cpServerv4Lease) [Add-DhcpServerv4Lease], CimException
  • FullyQualifiedErrorId : DHCP 20014,Add-DhcpServerv4Lease

PS C:\Users\Administrator>

PS C:\Users\Administrator> Get-DhcpServerv4Lease -ScopeId 14.0.0.0 -BadLeases
PS C:\Users\Administrator>
PS C:\Users\Administrator> Get-DhcpServerv4Lease -ScopeId 14.0.0.0 -ClientId "42-2e-7c-b0-a7-c8"

IPAddress ScopeId ClientId HostName AddressState LeaseExpiryTime


14.0.0.2 14.0.0.0 42-2e-7c-b0-a7-c8 Expired 8/4/2022 1:38:13 AM

For other scopes it is working fine, I can delete the scope and recreate it but want to know what is the mistake or condition that DHCP server went into it

Thanks in Advance

Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.6K Reputation points MVP Volunteer Moderator
    2022-08-04T11:09:25.977+00:00

    Hi @Surya Shetty ,

    if you use Add-DhcpServerv4Lease PowerShell is trying to add the Lease. This is not possible because the Lease still exists (you verified this with Get-DhcpServerv4Lease).
    As there is no "update lease" PowerShell cmdlet your only option is to delete the existing Lease (Remove-DhcpServerv4Lease) and add a new Lease afterwards with Add-DhcpServerv4Lease .

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

  2. Limitless Technology 39,926 Reputation points
    2022-08-05T15:42:32.817+00:00

    Hi there,

    For some reason, if you still find the old DHCP lease time values on your device, make a forced change. For this, type ipconfig /release followed by ipconfig /renew. The first command releases the resources, while the second command establishes a new connection with the new DHCP lease time.

    Also check the event viewer for and id created during the script failure.

    ------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.