How to Analyze DHCP Server with PowerShell

How to Analyze DHCP Server with PowerShell

How to Analyze DHCP Server with PowerShell. DHCP is a network management protocol that assigns an IP to each device on the network so that it can communicate with others over the network. DHCP manages these settings automatically and centrally, and network administrators do not need to manually assign IP addresses to all devices. DHCP can be implemented in small local area networks as well as large enterprise networks.

DHCP automatically assigns a new IP to a device when it moves over the network. A DHCP server is a critical component of the IT infrastructure in most environments. In addition to monitoring, which ensures the basic availability of the service, you may also want to check the status of the IP scopes or leases. PowerShell provides several cmdlets for this purpose.

In this article, we will teach you how to analyze DHCP Server with PowerShell. Stay with us.


Choose your perfect Windows Virtual Private Server Packages in Eldernode


The commands for managing Windows-based DHCP servers are part of the DhcpServer module, which can be obtained by installing the RSAT for DHCP. The cmdlets mentioned here are particularly useful for analyzing problems that arise.

Recommended Article: Learn important PowerShell commands

How to Identify all servers and query their settings

The first step is to retrieve a list of servers that offer the DHCP service to the network. This is especially important for larger environments with several DHCP servers.

The Get-DhcpServerInDC cmdlet will do the job and is usually invoked without parameters.

For further use in other commands, you can store the names of the returned servers in a variable:

$dhcps = (Get-DhcpServerInDC).DnsName

The cmdlet returns a list of DHCP servers registered in Active Directory. This means that you will not find rogue DHCP servers that were connected to the network without the knowledge of the IT department.

Some basic settings of a DHCP server, such as whether it is a member of the domain and is authorized, can be retrieved with the following query:

Get-DhcpServerSetting -ComputerName <MyDHCP>

This cmdlet will also tell you whether the data has been restored from a backup. This and other information about the database can also be obtained from the following query:

Get-DhcpServerDatabase -ComputerName <MyDHCP>


Get-DhcpServerAuditLog -ComputerName <MyDHCP>

you can find out whether logging has been activated for the DHCP service and where the log file is stored.

However, you cannot display the log content with this command. Instead, you have to evaluate this text file yourself.


Dedicated cmdlets for IPv4 and IPv6

Most of the module’s functions are available in two versions.

The functions all have a ‘4‘ or a ‘6‘ in their names because they relate to IPv4 or IPv6, respectively. The following examples for IPv4 can therefore be applied to IPv6:

To get statistics on the DHCP service for IPv4 as a whole, use:

Get-DhcpServerv4Statistics -ComputerName <MyDHCP>

The statistics contain numbers that you can also get by evaluating individual scopes, but here are the totals for all scopes.

Getting IPv4-related statistics for a DHCP server using Get-DhcpServerv4Statistics


How to Analysis of scopes

Most queries, whether they are about available IP addresses, assigned leases, or general statistics, refer to specific scopes. You can enumerate them using Get-DhcpServerv4Scope.

For example, if you want to output all scopes of all DHCP servers to see whether there is an overlap between them, you could proceed as follows:

$dhcps = (Get-DhcpServerInDC).DnsName  $dhcps | foreach {Get-DhcpServerv4Scope -ComputerName $_}

To get an overview of the most important figures for IPv4 scopes of a DHCP server, use the following:

Get-DhcpServerv4ScopeStatistics -ComputerName <MyDHCP>

This command tells you the percentage of a scope that is already being used and how many addresses are already taken or are still available.


How to Analyze DHCP Server with PowerShell


Free, assigned and reserved addresses

The data for free addresses can be obtained with Get-DhcpServerv4FreeIPAddress.

Note: If you retrieve it just using the ScopeID parameter, you will only get the next free address.

To fetch more available addresses, you have to enter a value for NumAddress:

DhcpServerv4FreeIPAddress -ComputerName <MyDHCP> -ScopeId `  -StartAddress -NumAddress 20

This example lists 20 free addresses, starting from


How to Analyze DHCP Server with PowerShell


You might like to know which addresses have already been assigned to devices:

Get-DhcpServerv4Lease -ComputerName <MyDHCP> -ScopeId

In the output of this function, you will find the MAC address of the clients and the status of the leases as additional information.


How to Analyze DHCP Server with PowerShell


In addition to the free and already assigned addresses, there are usually also addresses that have been reserved for devices with a fixed IP. These can be queried as follows:

Get-DhcpServerv4Reservation -ComputerName <MyDHCP> -ScopeId

Note: If a client isn’t able to receive an address, you can check to see whether it appears on the deny list:

Get-DhcpServerv4Filter -ComputerName <MyDHCP>



The module DhcpServer contains a total of 121 commands that not only query the settings and their status but can also configure the service. The complete documentation can be found on Microsoft Docs.


Also, see:

IP settings in MikroTik

How to Install and Configure DHCP Server on Windows Server 2019

Recommended Article: How to install Java with Apt on Debian 10

Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problem in it as soon as possible. Make time for other users and experts to answer your questions.

How to Analyze DHCP Server with PowerShell.


How useful was this post?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day