PowerShell:删除-DhcpServerv4Lease不会删除现有的租约

我想从服务器WSKELLER中删除所有DHCP租约和预留。 从文档我似乎明白,这将是完成的:

Get-DhcpServerv4Scope -ComputerName WSKELLER | Remove-DhcpServerv4Lease -ComputerName WSKELLER 

该cmdlet确实find所有的租约,但它为每个租约抛出以下错误:

 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 

显然我犯了一些错误。 但是哪一个?

从您的错误: + FullyQualifiedErrorId : DHCP 20019,Remove-DhcpServerv4Lease

来自: https : //msdn.microsoft.com/en-us/library/windows/desktop/aa363378(v=vs.85).aspx

ERROR_DHCP_RESERVED_CLIENT 20019指定的DHCP客户端是保留的客户端。

看起来你正试图删除一个保留。 如果这是故意的,那么您将需要使用Remove-DhcpServerv4Reservation cmdlet。