{"id":82502,"date":"2022-08-30T11:32:30","date_gmt":"2022-08-30T11:32:30","guid":{"rendered":"https:\/\/ded9.com\/?p=82502"},"modified":"2025-11-20T07:24:34","modified_gmt":"2025-11-20T07:24:34","slug":"how-to-analyze-dhcp-server-with-powershell-on-windows-servers","status":"publish","type":"post","link":"https:\/\/ded9.com\/tr\/how-to-analyze-dhcp-server-with-powershell-on-windows-servers\/","title":{"rendered":"Analyzing DHCP Servers on Windows with PowerShell: A Comprehensive Guide"},"content":{"rendered":"<p>Dynamic Host Configuration Protocol (DHCP) is a network management protocol that automatically assigns IP addresses to devices on a network. This automation simplifies network administration, eliminating the need for manual IP configuration. DHCP is essential in both small local networks and large enterprise environments, ensuring seamless connectivity.<\/p>\n<p>One of the key aspects of DHCP management is monitoring and analyzing the DHCP server to ensure its optimal performance. <a href=\"https:\/\/en.wikipedia.org\/wiki\/PowerShell\" target=\"_blank\" rel=\"noopener\">PowerShell<\/a> provides a powerful set of cmdlets to retrieve crucial DHCP data, diagnose issues, and manage settings efficiently.<\/p>\n<p>In this article, we will explore how to analyze a DHCP server using PowerShell. You will learn how to retrieve server information, check IP address allocations, analyze logs, and more.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-254427 size-full\" src=\"https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/Windows-Servera-DHCP.jpg\" alt=\"Analyzing DHCP Servers on Windows with PowerShell: A Comprehensive Guide\" width=\"1280\" height=\"720\" srcset=\"https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/Windows-Servera-DHCP.jpg 1280w, https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/Windows-Servera-DHCP-300x169.jpg 300w, https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/Windows-Servera-DHCP-1024x576.jpg 1024w, https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/Windows-Servera-DHCP-768x432.jpg 768w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<h2>Prerequisites: Installing the DHCP Server Module<\/h2>\n<p>To manage Windows-based DHCP servers, you must install the DHCP Server module, which is part of the Remote Server Administration Tools (RSAT). Ensure that RSAT for DHCP is installed before proceeding with PowerShell commands.<\/p>\n<h2>Identifying DHCP Servers on the Network<\/h2>\n<p>For effective DHCP analysis, the first step is identifying all <a href=\"https:\/\/ded9.com\/what-is-dhcp-and-how-does-it-work\/\">DHCP<\/a> servers in your environment. This is particularly important in larger networks with multiple DHCP servers.<\/p>\n<p>The following PowerShell command retrieves a list of DHCP servers registered in Active Directory:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerInDC<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">To store the server names in a variable for further analysis:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">$dhcps = (Get-DhcpServerInDC).DNSName<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">This command provides a list of DHCP servers available on your network. However, if a DHCP server is running but not registered in Active Directory, this method will not detect it.<\/p>\n<h2 data-pm-slice=\"1 1 []\">Retrieving Basic DHCP Server Settings<\/h2>\n<p>Once you have identified the DHCP servers, you can check their settings. The following command retrieves essential information about a specific DHCP server:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerSetting -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">This command provides details such as:<\/p>\n<ul data-spread=\"false\">\n<li>Whether the server is a domain member<\/li>\n<li>Whether it is authorized in Active Directory<\/li>\n<li>If its configuration was restored from a backup<\/li>\n<\/ul>\n<p>To retrieve additional database-related information, use:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerDatabase -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">To check if logging is enabled and where log files are stored:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerAuditLog -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">However, this command does not display the log content. You will need to manually review the log files for detailed analysis.<\/p>\n<h2 data-pm-slice=\"1 1 []\">IPv4 and IPv6 Specific Cmdlets<\/h2>\n<p>The DHCP Server module provides dedicated cmdlets for IPv4 and IPv6. Most cmdlets have a &#8220;4&#8221; or &#8220;6&#8221; suffix to indicate their respective IP versions. The following example retrieves general DHCP service statistics for IPv4:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4Statistics -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">This command provides an overview of DHCP service performance, including:<\/p>\n<ul data-spread=\"false\">\n<li>Number of active leases<\/li>\n<li>Available IP addresses<\/li>\n<li>Lease duration statistics<\/li>\n<\/ul>\n<p>For IPv6, use:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv6Statistics -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<h2 data-pm-slice=\"1 1 []\">Analyzing DHCP Scopes<\/h2>\n<p data-pm-slice=\"1 1 []\">DHCP scopes define the range of IP addresses available for lease. To retrieve all scopes on a DHCP server, run:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4Scope -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">To retrieve scope statistics, including the percentage of used and available addresses:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4ScopeStatistics -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">For multiple DHCP servers, you can analyze all scopes in the domain:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">$dhcps | ForEach-Object { Get-DhcpServerv4Scope -ComputerName $_ }<\/pre>\n<\/div>\n<h2 data-pm-slice=\"1 1 []\">Managing IP Address Allocations<\/h2>\n<p>To analyze DHCP address allocation, use the following commands:<\/p>\n<h3>Free IP Addresses<\/h3>\n<p>To retrieve available IP addresses within a scope:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4FreeIPAddress -ComputerName &lt;MyDHCP&gt; -ScopeId 192.168.0.0 -StartAddress 192.168.0.50 -NumAddress 20<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">This command checks for 20 available addresses starting from <code>192.168.0.50<\/code>.<\/p>\n<h3>Assigned IP Addresses<\/h3>\n<p>To retrieve a list of leased IP addresses:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4Lease -ComputerName &lt;MyDHCP&gt; -ScopeId 192.168.0.0<\/pre>\n<\/div>\n<p data-pm-slice=\"1 1 []\">This command provides:<\/p>\n<ul data-spread=\"false\">\n<li>Assigned IP addresses<\/li>\n<li>MAC addresses of clients<\/li>\n<li>Lease expiration details<\/li>\n<\/ul>\n<h3>Reserved IP Addresses<\/h3>\n<p>Reserved addresses are assigned to specific devices with static IPs. To retrieve reserved addresses:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4Reservation -ComputerName &lt;MyDHCP&gt; -ScopeId 192.168.0.0<\/pre>\n<\/div>\n<h3 data-pm-slice=\"1 1 []\">Checking for Blocked Clients<\/h3>\n<p>If a client is unable to obtain an IP address, check whether it appears in the deny list:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">Get-DhcpServerv4Filter -ComputerName &lt;MyDHCP&gt;<\/pre>\n<\/div>\n<h2 data-pm-slice=\"1 1 []\"><img decoding=\"async\" class=\"aligncenter wp-image-254424 size-full\" src=\"https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/dhcp-2.jpg\" alt=\"Checking for Blocked Clients\" width=\"728\" height=\"250\" srcset=\"https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/dhcp-2.jpg 728w, https:\/\/ded9.com\/wp-content\/uploads\/2022\/08\/dhcp-2-300x103.jpg 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/h2>\n<h2 data-pm-slice=\"1 1 []\">Conclusion<\/h2>\n<p>PowerShell provides an extensive set of tools for managing and analyzing DHCP servers efficiently. The DHCP Server module includes 121 cmdlets, allowing administrators to retrieve detailed information, monitor leases, and manage IP allocation dynamically. By leveraging these commands, IT professionals can maintain a robust and well-monitored DHCP infrastructure.<\/p>\n<p>For further automation, PowerShell scripts can be created to monitor DHCP status, detect potential issues, and generate reports for proactive network management.<\/p>\n<h2>FAQ<\/h2>\n<div id=\"rank-math-rich-snippet-wrapper\"><div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-1\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What PowerShell module is required to manage a Windows DHCP server?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>You need the DhcpServer module, which is included in RSAT for DHCP.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-2\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How can I list all DHCP servers registered in Active Directory?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Use Get-DhcpServerInDC to return the DNS names of all DHCP servers.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-3\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How do I check the number of active leases and available IP addresses on a DHCP server?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Run Get-DhcpServerv4Statistics -ComputerName to view lease counts, free addresses, and other usage stats.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Dynamic Host Configuration Protocol (DHCP) is a network management protocol that automatically assigns IP addresses to devices on a network. This automation simplifies network administration, eliminating the need for manual IP configuration. DHCP is essential in both small local networks and large enterprise environments, ensuring seamless connectivity. One of the key aspects of DHCP management [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":82503,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4909],"tags":[4881,4910,934,4911],"class_list":["post-82502","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-server","tag-dhcp","tag-powershell","tag-server","tag-windows-servers"],"acf":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts\/82502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/comments?post=82502"}],"version-history":[{"count":3,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts\/82502\/revisions"}],"predecessor-version":[{"id":254418,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/posts\/82502\/revisions\/254418"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/media\/82503"}],"wp:attachment":[{"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/media?parent=82502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/categories?post=82502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ded9.com\/tr\/wp-json\/wp\/v2\/tags?post=82502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}