I want to delete all DHCP leases and reservation from server WSKELLER. From the documentation I seem to understand that this would be accomplished with:
Get-DhcpServerv4Scope -ComputerName WSKELLER | Remove-DhcpServerv4Lease -ComputerName WSKELLER
The cmdlet does find all the leases, yet it throws for each lease the following error:
Remove-DhcpServerv4Lease : Failed to delete lease 10.10.12.32 from scope 10.10.0.0 on DHCP server WSKELLER.
At C:\admin\removeDhcpDns.ps1:8 char:48
+ ... mputerName WSKELLER | Remove-DhcpServerv4Lease -ComputerName WSKELLER +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (10.10.12.32:root/Microsoft/...cpServerv4Lease) [Remove-DhcpServerv4Lease], CimException
+ FullyQualifiedErrorId : DHCP 20019,Remove-DhcpServerv4Lease
Obviously I am doing some mistake. But which one?
From your error:
+ FullyQualifiedErrorId : DHCP 20019,Remove-DhcpServerv4Lease
From: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363378(v=vs.85).aspx
It looks like you're trying to delete a reservation. If that is intentional, then you will need to use the
Remove-DhcpServerv4Reservation
cmdlet instead.