Hi folks,
If you are working in a multi-domain forest and you need to retrieve a list of domains there are coule ways to achieve, either using ADSI as in this post or write function as this blog post. Both are work.
However there's a simple way to achieve it if you are running Windows 2008 R2 and later and AD PowerShell module. You can achieve this simply by running:
Get-ADForest |select -ExpandProperty Domains
An you will get list of all domain FQDNs within your forest.
Enjoy.
If you are working in a multi-domain forest and you need to retrieve a list of domains there are coule ways to achieve, either using ADSI as in this post or write function as this blog post. Both are work.
However there's a simple way to achieve it if you are running Windows 2008 R2 and later and AD PowerShell module. You can achieve this simply by running:
Get-ADForest |select -ExpandProperty Domains
An you will get list of all domain FQDNs within your forest.
Enjoy.