PowerShell Logo Small

Get-ADForest



This is the built-in help made by Microsoft for the command 'Get-ADForest', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Gets an Active Directory forest.

SYNTAX


Get-ADForest [-AuthType {Negotiate | Basic}] [-Credential <PSCredential>] [-Current {LocalComputer | LoggedOnUser}] [-Server <String>] [<CommonParameters>]
Get-ADForest [-Identity] <ADForest> [-AuthType {Negotiate | Basic}] [-Credential <PSCredential>] [-Server <String>] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Get-ADForest cmdlet gets the Active Directory forest specified by the parameters. You can specify the forest by setting the Identity or Current parameters.


The Identity parameter specifies the Active Directory forest to get. You can identify a forest by its fully qualified domain name (FQDN), DNS host name, or NetBIOS name. You
can also set the parameter to a forest object variable, such as $<localForestObject>, or you can pass a forest object through the pipeline to the Identity parameter.


To retrieve the forest of the local computer or current logged on user (CLU) set the Current parameter to LocalComputer or LoggedOnUser. When you set the Current parameter,
you do not need to set the Identity parameter.


When the Current parameter is set to LocalComputer or LoggedOnUser, the cmdlet uses the Server and Credential parameter values to determine the domain and the credentials to
use to identify the domain of the forest according to the following rules:


- If both the Server and Credential parameters are not specified:


-- The domain is set to the domain of the LocalComputer or LoggedOnUser and a server is located in this domain. The credentials of the current logged on user are used to get
the domain.


- If the Server parameter is specified and the Credential parameter is not specified:


-- The domain is set to the domain of the specified server and the cmdlet checks to make sure that the server is in the domain of the LocalComputer or LoggedOnUser. Then the
credentials of the current logged on user are used to get the domain. An error is returned when the server is not in the domain of the LocalComputer or LoggedOnUser.


- If the Server parameter is not specified and the Credential parameter is specified:


-- The domain is set to the domain of the LocalComputer or LoggedOnUser and a server is located in this domain. Then the credentials specified by the Credential parameter
are used to get the domain.


- If the Server and Credential parameters are specified:


The domain is set to the domain of the specified server and the cmdlet checks to make sure that the server is in the domain of the LocalComputer or LoggedOnUser. Then the
credentials specified by the Credential parameter are used to get the domain. An error is returned when the server is not in the domain of the LocalComputer or LoggedOnUser.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=291031
Set-ADForest
Set-ADForestMode

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>Get-ADForest -Identity Fabrikam.com



This command gets the forest information of the Fabrikam.com forest.




-------------------------- EXAMPLE 2 --------------------------

PS C:\>Get-ADForest -Current LocalComputer



This command gets the forest information of the current local computer's forest.




-------------------------- EXAMPLE 3 --------------------------

PS C:\>Get-ADForest -Current LoggedOnUser



This command gets the forest information of the current logged on users's forest.




-------------------------- EXAMPLE 4 --------------------------

PS C:\>Get-ADForest
ApplicationPartitions : {DC=ForestDnsZones,DC=Fabrikam,DC=com, DC=DomainDnsZones,DC=Fabrikam,DC=com}
CrossForestReferences : {CN=northwind,CN=Partitions,CN=Configuration,DC=Fabrikam,DC=com}
DomainNamingMaster : Fabrikam-DC1.Fabrikam.com
Domains : {Fabrikam.com}
ForestMode : Windows2003Forest
GlobalCatalogs : {Fabrikam-DC1.Fabrikam.com, CSD2722780.Fabrikam.com}
Name : Fabrikam.com
PartitionsContainer : CN=Partitions,CN=Configuration,DC=Fabrikam,DC=com
RootDomain : Fabrikam.com
SchemaMaster : Fabrikam-DC1.Fabrikam.com
Sites : {Default-First-Site-Name, UnitedKingdomHQ, BO3, RODC-Site-Name}
SPNSuffixes : {}
UPNSuffixes : {}



This command gets the forest information for the forest of the currently logged on user.




-------------------------- EXAMPLE 5 --------------------------

PS C:\>$allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }



This command gets a list of all the domain controllers for all domain within a forest.