PowerShell commands are an easy way to save a lot of time as system administrator. In this article, I'll show you how to configure DHCP from PowerShell. I have following information including scope, and router gateway IP.



Following is the configuration break down:

  1. Installing DHCP
  2. Adding DHCP scope
  3. Adding DNS server, and router gateway options
  4. Setting lease duration for a scope
  5. Restarting DHCP service

Step-by-Step Instructions

Step 1: Install DHCP Server Role

PowerShell Command:

Install-WindowsFeature -Name 'DHCP' –IncludeManagementTools

Step 2: Add DHCP Scope

PowerShell Command:

Add-DhcpServerV4Scope -Name "DHCP Scope" -StartRange -EndRange -SubnetMask

Step 3: Add DNS Server, Router Gateway Options in DHCP

PowerShell Command:

Set-DhcpServerV4OptionValue -DnsServer -Router

Step 4: Set Up Lease Duration

PowerShell Command:

Set-DhcpServerv4Scope -ScopeId -LeaseDuration 1.00:00:00

Step 5: Restart DHCP Service

PowerShell Command:

Restart-service dhcpserver

That's all. With 5 PowerShell commands, you installed and configured a complete DHCP server.

How to Configure DHCP with PowerShell

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

One thought on “How to Configure DHCP with PowerShell

  • Avatar
    February 18, 2020 at 6:14 am

    This command is not work “Add-DhcpServerV4Scope -Name “DHCP Scope” -StartRange -EndRange -SubnetMask″ So Please help me..


Leave a Reply

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