Last active
February 2, 2022 17:00
-
-
Save SweetAsNZ/c07f2c7fe6718ee41ae3fa26b98e9241 to your computer and use it in GitHub Desktop.
Checks if there are clients in subnets that are not in AD Sites and Services
This file contains 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
<# | |
.SYNOPSIS | |
Parses the netlogon.log on DC's to find where there are client logins but no AD Sites and Services Subnet. | |
.DESCRIPTION | |
'# WIP' Means it is still a Work In Progress | |
################################################################## | |
## Author: Tim West ## | |
## Company: Sweet As Chocolate Ltd ## | |
## Email/IM: ## | |
################################################################## | |
.PARAMETER Name | |
N/A | |
.PARAMETER Extension | |
N/A | |
.INPUTS | |
N/A | |
.OUTPUTS | |
Log File | |
.EXAMPLE | |
Just Run it | |
.LINK | |
#> | |
function Get-ADNoClientSite{ | |
# Checks if there are clients in subnets that are not in AD Sites and Services | |
$ADClientSite = "C:\Scripts\AD\AD_No_Client_Site" | |
if(!(Test-Path $ADClientSite)){ | |
New-Item $ADClientSite -ItemType Directory | |
} | |
Set-Location $ADClientSite | |
$DCs = (Get-ADDomain).ReplicaDirectoryServers | Sort-Object | |
foreach ($item in $DCs) | |
{ | |
$item | |
$Log = Get-Content "\\$($Item)\C$\Windows\Debug\Netlogon.log" | Select-String -AllMatches "NO_CLIENT_SITE" | |
$Log -replace "^.*?AKL: " -replace "NO_CLIENT_SITE: " | Sort-Object | Get-Unique | Out-File "$ADClientSite\NoSiteError_$($Item).log" | |
Write-Host "Check Site $($ADClientSite)\NoSiteError_$($Item).log" | |
Notepad "$ADClientSite\NoSiteError_$($Item).log" | |
}#END FOREACH | |
}#END FUNCTION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment