You are on page 1of 12
‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops Analyze DHCP server with PowerShell Home (httos:/4sysops.com) / Blog (https:/4sysops.comvarchives!) / Analyze DHCP server with PowerShell 4sysops - The online community for SysAdmins and DevOps Wolfgang Sommergut Mon. ua 102020 (https://4sysops.com/archives/analyze-dhcp-server-with-powershell/) networking, powershell 1 A DHCP server is a critical component of the IT infrastructure in most environments. It to monitoring, which ensures the basic availability of the service, you may also want the status of the IP scopes or leases. PowerShell provides several cmdlets for this purr Author Recent Posts Z Wolfgang Sommergut (Https://4sysops.Com/Members/Wolfgang-Sommerg htps:4sysops.com/archivesfanalyze-dhep-sorver-with-powershell we ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops Wolfgang Sommergut has over 20 years of experience in IT journalism. He has also worked as a syste trator and as a tech consultant. Today he runs the German publication Wine (http:swww.windowspro.de) (https://4s ysops.co mimembe rsiwolfga ng- som- mergut/) Contents of this article + Identifying all servers and querying their settings + Dedicated cmadlets for IPv4 and IPV6 + Analysis of scopes + Free, assigned, and reserved addresses The commands for managing Windows-based DHCP servers are part of the DhepServer mod can be obtained by installing the RSAT for DHCP. The cmdlets mentioned here are particul for analyzing problems that arise. htps:4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ane ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops Identifying all servers and querying their settings “ The first step is to retrieve a list of servers that offer the DHCP service to the network. Of cou especially important for larger environments with several DHCP servers. The Get-DhcpS (https://docs.microsoft.com/en-us/powershell/module/dhcpserver/get-dhcpserverindc? view=wi < cmdlet will do the job and is usually invoked without parameters. > However, for further use in other commands, you can store the names of the returned se variable: 1. $dh erverInDC) . DnsName (Get-Di As the name suggests, the cmdlet returns a list of DHCP servers registered in Active Dire means that you will not find rogue DHCP servers that were connected to the network without edge of the IT department. M htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ane ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops Some basic settings of a DHCP server, such as whether it is a member of the domain anc rized, can be retrieved with the following query: verSetting -ComputerNar This cmdlet will also tell you whether the data has been restored from ,< (https://4sysops.com/archives/dhcp-backup-and-restore/). This and other information about base can also be obtained from the following query: 1. Get-Dhep. Database —ComputerName With 1. Get-Dhep. rAudithog -ComputerName you can find out whether logging has been activated for the DHCP service and where the stored. However, you cannot display the log content with this command. Instead, you have t 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 @Zor a names because they relate to IPv4 or IPv6, respectively. The following examples for IPv4 car be applied to IPv6: htps:4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ana ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops To get statistics on the DHCP service for IPv4 as a whole, use: 1. Get-DhepServervdstatis -ComputerName The statistics contain numbers that you can also get by evaluating individual scopes, but he totals for all scopes. 1. Getting TPv4-related sta es for a DHCP server using Get-DhepServervéstat Analysis of scopes * Most queries, whether they are about available IP addresses, assigned leases, or general ste fer to specific scopes. You can enumerate them using Get-DhcpServe (https://docs.microsoft.com/en-us/powershell/module/dhcpserver/get-dhepserverv4scope?viev ps). If, for example, you want to output all scopes of all DHCP servers to see whether there i lap between them, you could proceed as follows: rverInDC) .DnsName DhepServerv4Scope ~: ComputerName $_} To get an overview of the most important figures for IPv4 scopes of a DHCP server, use the fo 1. Get-DhepServervascopestatistics -ComputerNane < > This command tells you the percentage of a scope that is already being used and how many : are already taken or are still available. htps:4sysops.com/archivesfanalyze-dhep-sorver-with-powershell siz ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops (nttps#4sysops. con/wp-contont/uploads/2020/08/Outputstatistics-ortho-individual-IPv4.scopes png) Output statistics for the individual IPv4 scopes Free, assigned, and reserved addresses * The data for free addresses can be obtained with Get-DhcpServerv4FreelPAdaress. If you just using the ScopelD parameter, you will only get the next free address, To fetch more avi dresses, you have to enter a value for NumAddress: 1. Dhepse: tartAddress 192.168.0.59 -NumAddress 20 exvéFreeIPAddress —ComputerName -ScopeId 192.168.0.0 This example lists 20 free addresses, starting from 192.168.0.59. htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ez ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops {ntips:/4sysops. com/wp-content/uploads/2020/08/Outputing tree-addresses-of-2-scope png) Outputting free addresses of a scope To complement this, you might like to know which addresses have already been assigned to d 1. Get-DhepServervdLease -ComputerName -ScopeTd 192.168.0.0 In the output of this function, you will find the MAC address of the clients and the status of the additional information. (htips:/4sysops.com/wp-contentuploads/2020/08/Displaying-iesued-leases-of-2-scope.png) htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell me ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops Displaying issued leases of a scope In addition to the free and already assigned addresses, there are usually also addresses been reserved for devices with a fixed IP. These can be queried as follows: 1. Get-DhepServerviReservation -ComputerName -Scopetd 192.168.0.0 Ifa client isn't able to receive an address, you can check to see whether it appears on the den Subscribe to 4sysops newsletter! Email address 1. Get-DhepServerv4Filter -ComputerName The module DhepServer contains a total of 121 commands that not only query the settings status but can also configure the service. The complete documentation can be found on Micre (https://docs.microsoft.com/en-us/powershell/module/dhcpserver/?view=win10-ps). 45 htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ane ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops (https://4sysops.com/members/paolo/) (https://4sysops.com/members/msand3rs/) Join the 4sysops PowerShell group! (https://4sysops.com/groups/powershel utm_source=4sysops&utm_medium=endpage&utm_campaign=PowerShell&utm_term= Your question was not answered? Ask in the forum! (https://4sysops.com/groups/powershelliforum/? utm_source=4sysops&utm_medium=endpage&utm_campaign=PowerShellForul RELATED ARTICLES. < (https://4sysops.com/ar« (https://4sysops.com/ar: (https://4sysops.com/arc (https://4sysops. vhdx-compress- communications- powershell-scripts- _ powershell-with- multiple-vhdx-files- __system-phone- remotely-on-azure- _resource-graph- using-the-powershell- _system-for-windows- _virtual-machines/) queries-in-azure! cmdlet-optimize-vhd/) linux-and-the-cloud!) Running PowerShell Boost PowerSh Compress-Vhdx: 3X scripts remotely on _ with Resource Compress multiple communications Azure virtual Graph queries ii VHDX files using the system: Phone machines Azure PowerShell cmdlet system for Windows, _(https://4sysops.com/z (https://4sysops Optimize-VHD Linux, and the cloud powershell-scripts- __ powershell-with (https://4sysops.com/: (https://4sysops.com/: remotely-on-azure-_resource-graph vhdx-compress- communications- _virtual-machines/) _queries-in-azure multiple-vhdx-files- _ system-phone- using-the- system-for-windows- — Mi powershell-cmdlet- linux-and-the-cloud/) With organizations Can you ifeigine moving more long it would take optimize-vhd/) workloads into Azure, generate a list of htps:4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ona ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops (https://4sysops.com/archives/virtual-training-in-the,age-pf-covid-19/) (https://4sysops.com/archives/vmware-vsan-2-nodes-whats-new-in-vsphere-7-0/) JC Moriaud 4 year ago Very good article thanks. Can | add that the command to to load PoSh DHCPServer module is : Add-WindowsFeature -Name DHCP —IncludeManagementTools “ REPLY (HTTPS:/i4SOPS,COM/ARCHIVES/ANALYZE-DHCP-SERVER-WITH-POWERSHELL/7REPLYTOCOM=912227H#RESPONI Leave a reply Please enclose code in pre tags Your email address will not be published. Required fields are marked * < Comment > Name * Email * Website htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell so ‘112821, 505 PM Analyze OHCP server with PowerShell | 4sysops CO. Notify me of followup comments via e-mail. You can also subscribe (https://4sysops.com/comment-subscripti: srp=15573858srk=0e33 169b89¢3(528241di6927b/36ee1 &sra=s&srsrc=f) without commenting. POST COMMENT G_ Receive new post notifications Subscribe to post notifications Name Email Address ‘email@domain.com | (http:/Awitter-com/4sysops/) (Gj (rt Facebook com/4sysops) 6 (https://www.linkedin.com/company/4sysops/) (https://4sysops.com/feed/) htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell ne ‘12424, 505 PM Analyze OHCP server with PowerShell | 4sysops © 4sysops 2006 - 2021 htpss4sysops.com/archivesfanalyze-dhep-sorver-with-powershell sane

You might also like