How to Configure DHCP with PowerShell

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.

Leave a Comment