How to Delete Multiple DHCP Scopes Using PowerShell

You can remove multiple scopes from your DHCP server by using this simple script which uses the Remove-DhcpServerv4Scope PowerShell cmdlet.

The script assumes you have scope IDs in a series (I have scope IDs of 10.0.0.0, 11.0.0.0 and 12.0.0.0).

Delete Multiple DHCP Scopes Using PowerShell

Step 1. Open notepad and copy/paste the following script and save the file with .ps1 extension. Be sure to replace your DHCP name in the script and loop variables (according to the range of scopes you have)

for ($i = 10;$i -lt 13;$i++)

{

$ScpID = $i.ToString() + ".0.0.0"

Remove-DhcpServerv4Scope -computername "Server2016.yourdomain.com" -ScopeId $ScpID -Force

}

Step 2. Open PowerShell with elevated privileges and execute the above script from step 1