Share via

Looking for a Powershell script to get which partnered dhcp server is used from win10 clients (base of 3000+ clients.)

Anonymous
2023-04-12T15:21:06.7333333+00:00

Hi; Having issues when we (DHCP) partnered a WIN2k19 server with an established WIN2k16 DHCP server. We have two DHCP servers serving over 3000 Win10 clients in a load balanced config. I would like to know which of the partnered DHCP servers the clients are being served IP's from. I don't know Powershell, but I'm sure there's a script out there for this, that would gather the info at login, and pipe the result to a specified network location. Thanks.

Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Rich Matheisen 48,116 Reputation points
    2023-04-13T18:49:59.55+00:00

    Which interfaces on the DHCP servers are receiving the UDP broadcast packets that the DHCP clients send when they're newly configured or when they don't get a reply to that packet? Is it only the load-balanced IP address? This will get you the information from the client machines. You can add the name of the client machine to the data by adding another key to the hash. Get the machine name from the client machines' environment variables. Package the script as a scriptblock in an Invoke-Command and use the Invoke-Commands' -ComputerName parameter with an array holding the names of all the DHCP client machines.

    Get-CimInstance Win32_NetworkAdapterConfiguration |
        ForEach-Object{
            try{
                $d = Get-NetAdapter -InterfaceDescription $_.Description -IncludeHidden -ErrorAction STOP
            }
            Catch{          # maybe not every "InterfaceDescription" will be found by Get-NetAdapter
                $d = @{}
            }
            [PSCustomObject][ordered]@{
                Description = $_.Description
                InterfaceIndexIndex = $d.InterfaceIndex
                DHCPEnabled = $_.DHCPEnabled
                DHCPServer = $_.DHCPServer
                DHCPLeaseObtained = $_.DHCPLeaseObtained
                DHCPLeaseExpires = $_.DHCPLeaseExpires
                IPAddress = $_.IPAddress
                'MAC Address' = $d.MacAddress
            }
        }
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.