Posted on March 10, 2016 · Posted in Powershell, Windows Server 2012 R2

How To Configure DHCP Server Using PowerShell

There is no familiar console to manage a DHCP server (Dhcpmgmt.msc) in RSAT for Windows 10, it is recommended to use the equivalent Powershell commands instead. Thus, it is gently suggested that in the coming Windows Server 2016 release, the DHCP server will be configured only from Powershell. In this article we’ll get acquainted with the main PowerShell commands in Windows Server 2012 R2 necessary to configure and manage a DHCP server.

To manage a DHCP server we need to load PoSh DHCPServer module. By default, this module is not loaded in PowerShell session. If you configure your DHCP server directly from it, install the DHCP role with management tools as follows:

Add-WindowsFeature -Name DHCP –IncludeManagementTools

If you manage a remote DHCP server, you have to install the corresponding RSAT component:

Add-WindowsFeature RSAT-DHCP

Add-WindowsFeature RSAT-DHCP

Before using it, import the DHCP module in your session:

Import-Module DHCPServer

Let’s see how many cmdlets are available in this module:

(Get-Command -Module DHCPServer).count

get-command DHCPServer

As many as 121! These cmdlets can be used to manage DHCP servers running Windows Server 2008 /R2 and Windows Server 2012 / R2.

Let’s display the list of authorized DHCP servers in Active Directory:


Display the list of authorized DHCP in AD

Get the list of DHCP scopes on a certain server:

Get-DhcpServerv4Scope –ComputerName seul-dhcp1

If more displayed fields are required (Delay, Description, Name, etc.):

Get-DhcpServerv4Scope –ComputerName seul-dhcp1| FL *


If the information about IPv6 scopes have to be displayed:


Get the settings of a certain scope:

Get-DhcpServerv4Scope –ComputerName seul-dhcp1 –ScopeID HelpDesk

To authorize a new DHCP server in Active Directory domain:

Add-DhcpServerInDC -DnsName -IPAddress

Create a new scope with this range of addresses to

Add-DHCPServerv4Scope -EndRange -Name Office -StartRange -SubnetMask -State Active –ComputerName seul-dhcp1

Configure the following DHCP server parameters: DNS server, domain and router address.

Set-DHCPServerv4OptionValue -ComputerName seul-dhcp1 -DnsServer -DnsDomain -Router

You can display the configured DHCP server options as follows:

Get-DHCPServerv4OptionValue -ComputerName seul-dhcp1 | Format-List

Configure the scope options:

Set-DHCPServerv4OptionValue -ComputerName seul-dhcp1 -ScopeId -DnsServer -DnsDomain

Display the list of the configured scope parameters:

Get-DHCPServerv4OptionValue -ComputerName seul-dhcp1 -ScopeId | Format-List

Exclude the range of addresses to from the addresses given out for a certain scope:

Add-Dhcpserverv4ExclusionRange -ComputerName seul-dhcp1 -ScopeId -StartRange -EndRange

Display the current list of the leased addresses for the scope

Get-DHCPServerv4Lease -ScopeId -ComputerName seul-dhcp1


Create a reservation for a client with the IP-address

Get-DhcpServerv4Lease -ComputerName seul-dhcp1 -IPAddress| Add-DhcpServerv4Reservation -ComputerName seul-dhcp1

You can perform a mass reservation of IP-addresses for computers listed in a CSV file. To do it, create a text file in the following format:

ScopeId,IPAddress,Name,ClientId,Description,,Client1,b3-ac-5c-fd-9e-6f,Reservation PC-seul-s1,,Client2,b3-ac-5c-fd-9e-3f,Reservation PC-seul-s2

Save this file as c:\dhcp\DHCP_Reservations.csv and run the next command that imports the data from the CSV file and creates reservations for the clients:

Import-Csv –Path c:\dhcp\DHCP_Reservations.csv | Add-DhcpServerv4Reservation -ComputerName seul-dhcp1

Deactivate a scope on a DHCP server:

Set-DhcpServerv4Scope -ComputerName seul-dhcp1 -ScopeId -State InActive

Activate a scope:

Set-DhcpServerv4Scope -ComputerName seul-dhcp1 -ScopeId -State Active

Remove a scope from a DHCP server:

Remove-DHCPServerv4Scope -ComputerName seul-dhcp1 -ScopeId -Force

You can get DHCP server statistics (the number of scopes and reservations, the percentage of used addresses, etc.).

Get-DhcpServerv4Statistics -ComputerName seul-dhcp1


The same information for a certain scope can be obtained using Get-DhcpServerv4ScopeStatistics cmdlet.

You can add DHCP server options (e. g., WPAD) as follows:

Add-DhcpServerv4OptionDefinition -ComputerName seul-dhcp1 -Name WPAD -OptionId 252 -Type String

DHCP server configuration can be exported in an XML file with the following command:

Export-DHCPServer -ComputerName seul-dhcp1 -File C:\dhcp\dhcp_export.xml

Tip. With the Scheduler task that contains this command you can regularly back up the DHCP server configuration.

Further, these DHCP server settings can be imported to another DHCP server (e. g., a server with the name seul-dhcp2):

Import-DHCPServer -ComputerName seul-dhcp2 -File C:\dhcp\dhcp_export.xml -BackupPath C:\dhcpbackup\


Related Articles