working on developing script which runs via schedule task ; whole purpose of it is to target few domain controllers and continuously(for every 2 sec) do a ldap query targeting that particular DC and dump the output to a csv find.Essentially, i am doing the below steps.
$root = [ADSI]"LDAP://CN=$TargetDCName,OU=Domain Controllers,DC=Fabricom,DC=com"
$search = [adsisearcher]$root
$Search.Filter = "(&(objectClass=computer))"
$Search.SearchScope = "base"
$Obj = $Search.Findone()
$Obj = $Obj.Path
$DateFormatted = Get-Date -uformat "%Y-%m-%d_%I-%M-%S-%p"
$Data = $DateFormatted + "," + $TargetDCName+ "," + "$Obj"
Add-Content -Path $Path -Value $Data
Now i am getting few doubts; 1.) Does what i am doing above make sense as LDAP connectivity check, since i am querying a DC using the same DC as a ROOT/Base.(Does the above code confirm that LDAP connectivity exists to that particular DC from any application which is correctly configured?)
2.) This question is regarding powershell , how to obtain LDAP error logs in powershell? I want to test it against a non existent or a DC which is shut down, what log event i should expect and how to capture it.
3.) Same as question 2, if DC is having replication issues, does it effect LDAP connectivity? what logs should be captured and how? Below are some of the replication errors , does any of these events cause issue to LDAP connectivity?
** -> (1256) The remote system is not available. For information about network troubleshooting, see Windows Help. ->(1722) The RPC server is unavailable. ->(8206) The directory service is busy. ->(8438) The directory service is too busy to complete the replication operation at this time.**
4.) How to Identify Latency of an LDAP query? Since this script runs on its own, is there a way to determine what time its took or measure its latency?
please do let me know if more information is required.