Hi folks,
Below is a quick script to retrieve domain controllers that are located in the same site as a computer on which your computer or server is located.
This is required for scenarios when you are trying to understand which DCs can be used for LDAP/GC queries by your computer or server.
So basically what it does it loads value of the AD site name where computer is located and feeds it to the $ADSite variable. Then it queries domain controllers by using $ADSite as a variable in order to retrieve domain controllers located in the same AD site:
$ADSite = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name
Get-ADDomainController -Filter {Site -eq "$ADSite"}
I hope you can find it helpful.
Enjoy!
Below is a quick script to retrieve domain controllers that are located in the same site as a computer on which your computer or server is located.
This is required for scenarios when you are trying to understand which DCs can be used for LDAP/GC queries by your computer or server.
So basically what it does it loads value of the AD site name where computer is located and feeds it to the $ADSite variable. Then it queries domain controllers by using $ADSite as a variable in order to retrieve domain controllers located in the same AD site:
$ADSite = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name
Get-ADDomainController -Filter {Site -eq "$ADSite"}
I hope you can find it helpful.
Enjoy!
No comments:
Post a Comment