How to enable DHCP using PowerShell

Enabling DHCP using PowerShell is very easy and can be accomplished in three lines of code. Yet for some reason many other online guides show the long way around.

I previously posted about how to set static IP’s using PowerShell. This script to enable DHCP can be a complementary program inside an SCCM package to configure IP addresses. That way, you can have an SCCM program to deploy a static IP and then another program to reset it back to DHCP, and both of these programs can be inside one package.

Alternatively, this script can be used as an Uninstall method if setting static IP’s using an application in SCCM, with a modified version of my network adapter configuration detection method script as the application detection method.

Either way, here is the short and simple script, with a log file output designed to add on to the previously mentioned Static IP script’s logs if they exist:

The first line selects the network adapters with IP addresses. The second line enables DHCP, and the third line resets the manually configured DNS servers. This should bring the computer back to the same network configuration state as before running the static IP script, assuming it was on DHCP at that time.

1 thought on “How to enable DHCP using PowerShell”

  1. Pingback: Programmatically Setting Static IP’s in a Computer Lab |

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.