You View the Dhcp Server Statistics Again

A DHCP server is a critical component of the IT infrastructure in most environments. In improver to monitoring, which ensures the basic availability of the service, y'all may also want to check the status of the IP scopes or leases. PowerShell provides several cmdlets for this purpose.

  • Writer
  • Recent Posts

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

Identifying all servers and querying their settings ^

The first stride is to think a list of servers that offering the DHCP service to the network. Of course, this is peculiarly important for larger environments with several DHCP servers. The Become-DhcpServerInDC cmdlet will do the job and is ordinarily invoked without parameters.

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

$dhcps = (Get-DhcpServerInDC).DnsName

As the proper noun suggests, the cmdlet returns a listing of DHCP servers registered in Active Directory. This ways that yous will not observe rogue DHCP servers that were connected to the network without the cognition of the IT department.

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

Go-DhcpServerSetting -ComputerName <MyDHCP>

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

Become-DhcpServerDatabase -ComputerName <MyDHCP>

With

Get-DhcpServerAuditLog -ComputerName <MyDHCP>

you can find out whether logging has been activated for the DHCP service and where the log file is stored. Yet, you cannot brandish the log content with this command. Instead, yous 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 'four' or a 'six' in their names because they chronicle to IPv4 or IPv6, respectively. The following examples for IPv4 tin therefore be applied to IPv6:

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

Become-DhcpServerv4Statistics -ComputerName <MyDHCP>

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

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

Analysis of scopes ^

Most queries, whether they are nigh available IP addresses, assigned leases, or full general statistics, refer to specific scopes. You tin can enumerate them using Get-DhcpServerv4Scope. If, for example, you want to output all scopes of all DHCP servers to run into whether there is an overlap between them, y'all could proceed as follows:

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

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

Get-DhcpServerv4ScopeStatistics -ComputerName <MyDHCP>

This control tells you the pct of a scope that is already beingness used and how many addresses are already taken or are still available.

Output statistics for the individual IPv4 scopes

Output statistics for the individual IPv4 scopes

Free, assigned, and reserved addresses ^

The data for free addresses can be obtained withGet-DhcpServerv4FreeIPAddress. If you lot call back it just using the ScopeID parameter, you volition only get the next free accost. To fetch more available addresses, you take to enter a value for NumAddress:

DhcpServerv4FreeIPAddress -ComputerName <MyDHCP> -ScopeId 192.168.0.0 ` -StartAddress 192.168.0.59 -NumAddress xx

This example lists 20 free addresses, starting from 192.168.0.59.

Outputting free addresses of a scope

Outputting free addresses of a scope

To complement this, you might like to know which addresses accept already been assigned to devices:

Get-DhcpServerv4Lease -ComputerName <MyDHCP> -ScopeId 192.168.0.0

In the output of this function, y'all will observe the MAC address of the clients and the status of the leases equally boosted information.

Displaying issued leases of a scope

Displaying issued leases of a scope

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 192.168.0.0

If a client isn't able to receive an address, you lot can check to see whether information technology appears on the deny listing:

Subscribe to 4sysops newsletter!

Get-DhcpServerv4Filter -ComputerName <MyDHCP>

The module DhcpServer contains a total of 121 commands that non just query the settings and their status but can besides configure the service. The complete documentation can be establish on Microsoft Docs.

avatar avatar

johnsonvould1969.blogspot.com

Source: https://4sysops.com/archives/analyze-dhcp-server-with-powershell/

0 Response to "You View the Dhcp Server Statistics Again"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel