How to delete DHCP scope in batch?

amoln 41 Reputation points
2022-08-01T01:13:46.127+00:00

I prepare two DHCP servers for failover, but the prompt indicates that some scopes already exist. I want to delete some scopes on the standby server, but it seems that I can only delete them one by one, which is a little too much. Can I delete scopes in batch

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

Answer accepted by question author
  1. Anonymous
    2022-08-01T02:20:08.74+00:00

    This example should work, just adjust the filter as needed.
    https://learn.microsoft.com/en-us/powershell/module/dhcpserver/remove-dhcpserverv4scope?view=windowsserver2022-ps#example-3-delete-all-disabled-scopes

    --please don't forget to upvote and Accept as answer if the reply is helpful--


2 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-08-01T01:25:19.243+00:00

    You can do it via PowerShell.
    https://learn.microsoft.com/en-us/powershell/module/dhcpserver/remove-dhcpserverv4scope?view=windowsserver2022-ps

    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

  2. Dillon Silzer 60,656 Reputation points Volunteer Moderator
    2022-08-01T01:27:32.317+00:00

    Hi @amoln

    You can remove DHCP scopes by invoking Remove-DhcpServerv4Scope in PowerShell. Create a .ps1 script and include all of the scopes that you want to delete.

    https://learn.microsoft.com/en-us/powershell/module/dhcpserver/remove-dhcpserverv4scope?view=windowsserver2022-ps

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

    If this is helpful please mark as correct answer.


Your answer

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