How to enumerate a domain GUID in an Active Directory forest

SharePoint 2013

We are in the process of combining the SharePoint Server 2013 and SharePoint Server 2016 content into a single content set. We appreciate your patience while we reorganize things. See the Applies To tag at the top of each article to find out which version of SharePoint an article applies to.

 

Applies to: OneDrive for Business, SharePoint Online

Topic Last Modified: 2016-12-16

Learn how an administrator can gather a list of domain GUIDs by using Windows PowerShell.

This article describes how to display a list of domain GUIDs with corresponding domain names by using Windows PowerShell.

NoteNote:
If the following error message is displayed: "The term [Get-ADForest]' is not recognized as the name of a cmdlet, function, script file, or operable program.", you might not have the Active Directory module loaded that contains the Active Directory cmdlets. To resolve this error message, use the Import-Module ActiveDirectory command in Windows PowerShell window or open ActiveDirectory Module for Windows Powershell.

  1. Open a Windows PowerShell 3.0 or 4.0 console window.

  2. To retrieve a list of domains from your Active Directory forest, type the following syntax from the Windows PowerShell command prompt:

     (Get-ADForest).Domains
    
  3. To retrieve a list of corresponding domain GUIDs of the domains you retrieved from Step 2, type the following syntax from the Windows PowerShell command prompt:

    $domains = (Get-ADForest).Domains; foreach($d in $domains) {Get-ADDomain -Identity $d | Select ObjectGuid} 
    

Show: