Find the DHCP Server

I had to find the dhcp server, but I can’t find any good method in Powershell. So I’m using Powershell to parse ipconfig /all.

$a = [string](ipconfig /all | findstr /C:"DHCP Server")
if ($a.Length -gt 0) {
$dhcpserver = $a.Substring($a.IndexOf("1"))
}

Which will take:

DHCP Server . . . . . . . . . . . : 10.10.4.2

And give you:

10.10.4.2
Advertisements