Guaranteeing DHCP servers have battle detection enabled with PowerShell

DHCP servers allow computerized distributions of IP addresses and IP choices to shopper units. Whether or not you have got carried out Home windows DHCP servers or third-party DHCP servers, you have to allow battle detection to keep away from leasing out conflicting IP addresses.

The issue if battle detection is disabled

If battle detection is just not enabled, the DHCP server can lease out an IP deal with that’s already is in use by one other machine. When battle detection is enabled, the DHCP Server will ping the IP deal with in query earlier than it leases out the IP deal with to a different requesting a shopper machine. If the DHCP server receives a reply from the ping, it would mark the IP deal with as BAD_ADDRESS and won’t lease out. Enabling battle detection on all DHCP servers is really helpful to make sure that all units have a singular IP deal with so community communication is just not halted. On this article, we’ll present a PowerShell script that may test the standing of all DHCP servers and their battle detection settings.

dhcp servers

Shutterstock

Necessities

Earlier than you’ll be able to run the PowerShell script offered under, be sure to meet these necessities:

  • You’ve gotten put in DHCP PowerShell cmdlets on the pc from the place you intend to run the script.
  • You’ve gotten collected all DHCP server names or IP addresses to be checked by the script and specified within the C:TempDHCPServers.TXT file.
  • All DHCP servers laid out in C:TempDHCPServers.TXT file are reachable from the pc from the place you intend to run the script.
  • The account you’re presently logged on to has permissions to entry properties of DHCP servers.

What does the script do?

The PowerShell script performs the next operations:

  • Checks all DHCP servers talked about within the C:TempDHCPServers.TXT file.
  • Imports DHCP server PowerShell cmdlets into the present PowerShell session.
  • Connects to every DHCP server utilizing Get-DHCPServerSetting and collects the server-side configuration.
  • Checks the battle detection standing and values after which information the output within the C:TempDHCPSettings.CSV file.

Vital: The script doesn’t write something to DHCP servers. The script simply executes Get-DHCPServerSetting, which is a read-only command, to assemble the required information and supply the leads to the CSV file.

PowerShell script

Executing this PowerShell script will generate a report in CSV format. The report file will be discovered at C:TempDHCPSettings.CSV.

$LocAppDataNow = "C:UsersPublic"
$CurrentLoc="C:Temp"
$UniqueTest="DHCPCD"
Import-Module DHCPServer
$TestCSVFile="C:TempDHCPSettings.CSV"
Take away-Merchandise $TestCSVFile -ErrorAction SilentlyContinue
$ThisString="DHCP Server, Conflict Detection Configured?, Value, Final Status"
Add-Content material "$TestCSVFile" $ThisString
$DHCPServerFile = "C:TempDHCPServers.TXT"
$AnyGap = "No"
ForEach ($Server in GC $DHCPServerFile)

IF ($AnyGap -eq "Yes")

$TestStatus="High"
$TestText="HIGH ISSUE"

else

As you’ll be able to see within the output under, which was generated by the script, the battle detection is not enabled on DC2.techthan.com and DC3.techthan.com DHCP Servers. The script additionally reveals the DHCP servers which have battle detection enabled and battle detection worth. After getting the output, you’ll be able to go browsing to the DHCP servers and configure the battle detection settings.

Vital: There are lots of different checks you need to carry out to maintain DHCP servers wholesome and operational. The above script was obtained from DynamicPacks IT Scanner, which is able to doing an entire well being evaluation of DHCP servers. There are 32 checks carried out and every test offers the information and affected settings.

Featured picture: Shutterstock


Submit Views:
81

Extra PowerShell Fundamentals articles






Learn Subsequent


About the Author

Leave a Reply

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