As an Active Directory administrator, you have to do recurring tasks. One task is to check if client subnets are pointed to an Active Directory site and if not Domain Controllers will log this message in the following log file and print a warning message at the event log.

EventLog ID: 5807 
EventLog Source: NETLOGON
EventLog Message:

During the past <hours> hours there have been <Number> connections to this Domain Controller from client machines whose IP addresses don't map to any of the existing sites in the enterprise. 
Those clients, therefore, have undefined sites and may connect to any Domain Controller including those that are in far distant locations from the clients. 
A client's site is determined by the mapping of its subnet to one of the existing sites. 
To move the above clients to one of the sites, please consider creating subnet object(s) covering the above IP addresses with mapping to one of the existing sites.  

The names and IP addresses of the clients in question have been logged on this computer in the following log file '%SystemRoot%\debug\netlogon.log' and, potentially, in the log file '%SystemRoot%\debug\netlogon.bak' created if the former log becomes full. 
The log(s) may contain additional unrelated debugging information. 
To filter out the needed information, please search for lines which contain text 'NO_CLIENT_SITE:'.
The first word after this string is the client name and the second word is the client IP address.
The maximum size of the log(s) is controlled by the following registry DWORD value 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters\LogFileMaxSize'; the default is 20000000 bytes.  The current maximum size is 20000000 bytes.  To set a different maximum size, create the above registry value and set the desired maximum size in bytes.

To get a list of Client IP Addresses that do not belong to an Active Directory Site, you can run this code snippet.

Import-Module -Name ActiveDirectory
$OU = (Get-ADDomain).DomainControllersContainer
$DomainControllers = Get-ADComputer -Filter * -SearchBase $OU
$PathNetlogon = 'Admin$\debug\netlogon.log'
$PathCsv = ('{0}\NO_CLIENT_SITE.csv' -f $HOME)
$PathIPSubnets = ('{0}\NO_CLIENT_SITE_Subnets.txt' -f $HOME)

$Pattern = 'NO_CLIENT_SITE'
[Object]$Content = $null

foreach ($DomainController in $DomainControllers) {
    # Define Path
    $Path = ('\\{0}\{1}' -f $DomainController.DNSHostName, $PathNetlogon)
    # Check Path
    if (Test-Path -Path $Path -ErrorAction SilentlyContinue) {
        Write-Host ('Getting logs from Server {0}:' -f $DomainController.Name) -ForegroundColor Green
        $Rows = Get-Content -Path $Path | Select-String -Pattern $Pattern 
        # Add Lines to variable
        $Content += $Rows
    }
}

# Export to Csv
$Content | 
    ConvertFrom-Csv -Delimiter ' ' -Header 'Date', 'Time', 'Id1', 'Domain', 'Type', 'Client', 'IPAddress' | 
    Export-Csv -Delimiter ',' -Path $PathCsv -NoTypeInformation

# Sort object
Import-Csv -Path $PathCsv | 
    Select-Object -Property $ExpClientIP | 
    Where-Object { $_.IP -like '*' } | 
    Group-Object -Property IP | 
    Sort-Object Count | 
    Select-Object Count, Name

# Define expression
$ExpClientIP = @{Name = 'IP'; Expression = { $($IP= ''; $IP = $_.IPAddress.Split('.'); ('{0}.{1}.{2}' -f $IP[0], $IP[1], $IP[2]) )}}

# Import as csv and write ip subnets to file
$Csv = Import-Csv -Path $PathCsv
$Csv | 
    Select-Object -Property $ExpClientIP | 
    Where-Object IP -NotMatch '169\.254' |
    Group-Object -Property IP | 
    Sort-Object Count | 
    Select-Object Count, Name | 
    Out-File -FilePath $PathIPSubnets

Have fun…

Leave a Reply

Your email address will not be published. Required fields are marked *