I’ve been doing a bit of work with DHCP over the last week or so – specifically with troubleshooting IP assignment from various VLANs. I threw together a quick function to read the last (x) lines out of the current day’s DHCP server log. For now, there’s no support for reading the logs remotely. This needs to be run on the server itself.
Once you’ve dot sourced the script, just call the function. By default, it will grab the last 20 lines out of the current day’s log file.
You can specify a day, and/or the number of lines to grab from the end of the log file:
Get-DHCPServerLog -Lines 5 -Day mon
You can also pipe it to Select-Object:
Get-DHCPServerLog | Select-Object Date,Time,Description,MAC*,IP* | Format-Table -AutoSize
Here’s the source: