Created
January 6, 2015 15:27
-
-
Save JFFail/6442b27225eb71b30d26 to your computer and use it in GitHub Desktop.
Script to pull the end of netlogon.log files on a list of DCs to check for entries in the last two months.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Get the list of servers. | |
$serverList = Get-Content -Path .\servers.txt | |
#Loop through each. | |
foreach($server in $serverList) { | |
#Get the contents of the netlogon file. | |
$netlogonContent = Get-Content -Path \\$server\C$\Windows\debug\netlogon.log -Tail 5 | |
#Boolean to only write the server name once if at all. | |
$serverNameWritten = $false | |
#Make another loop to go through the logs. | |
foreach($line in $netlogonContent) { | |
#Check the date. | |
if($line.Contains("01/") -or $line.Contains("12/")) | |
{ | |
#See if the server name should be written. | |
if(-not $serverNameWritten) { | |
Write-Host $server | |
Write-Host "========================================" | |
$serverNameWritten = $true | |
} | |
Write-Host $line | |
} | |
} | |
#Write more whitespace for readability *if* the server had any results that needed to be written. | |
if($serverNameWritten) { | |
Write-Host " " | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment