Quick PowerShell script to “tail -f” dhcp logs

When I am working in Linux, I like to leave a log open with “tail -f”, so I can see the results of some test I am performing.

The other day I wanted to see when a new machine joined the network, so I could give it a static DHCP lease. Usually I connect to the DHCP server find the DHCP logs and open them in notepad. I finally wrote a quick script to “tail -f dhcp.log” in PowerShell.

 

function JBM-AD-GetDHCPLogs {
 PARAM($ServerName="dhcpServerName")
 $FileName="DhcpSrvLog-$(get-date -format ddd).log"
 $PATH="\\$ServerName\c$\Windows\System32\dhcp\$FileName"
 Get-Content $path –Wait
 }

,

Comments are closed.

Powered by WordPress. Designed by WooThemes