Site icon TOSS

Get-ADForest

powershell

Get-ADForest is accessible with the help of addsadministration module. To install addsadministration on your system please refer to this link.

Synopsis

Gets an Active Directory forest.

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 $ 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.

Parameters

-AuthType 
         Specifies the authentication method to use. Possible values for this parameter include:

    Required?                    false
    Position?                    named
    Default value                Microsoft.ActiveDirectory.Management.AuthType.Negotiate
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Credential <PSCredential>
    Specifies the user account credentials to use to perform this task. The default credentials are the credentials of the currently logged on user unless the cmdlet is run from an Active Directory PowerShell provider drive. If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Current <ADCurrentForestType>
    Specifies whether to return the domain of the local computer or the current logged on user (CLU). Possible values for this parameter are:

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Identity <ADForest>
    Specifies an Active Directory forest object by providing one of the following attribute values. The identifier in parentheses is the LDAP display name for the attribute.

    Required?                    true
    Position?                    1
    Default value                
    Accept pipeline input?       True (ByValue)
    Accept wildcard characters?  false

-Server <String>
    Specifies the Active Directory Domain Services instance to connect to, by providing one of the following values for a corresponding domain name or directory server. The service may be any of the following:  Active Directory Lightweight Domain Services, Active Directory Domain Services or Active Directory Snapshot instance.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

Syntax

Get-ADForest [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-Current <ADCurrentForestType>] [-Server <String>] [<CommonParameters>]

Get-ADForest [-AuthType <ADAuthType>] [-Credential <PSCredential>] [-Identity] <ADForest> [-Server <String>] [<CommonParameters>]

Notes
This cmdlet does not work with AD LDS.

————————– EXAMPLE 1 ————————–
C:\PS>Get-ADForest TOSSolution.com
Get the forest information of the TOSSolution.com forest.

————————– EXAMPLE 2 ————————–
C:\PS>Get-ADForest -Current LocalComputer
Get the forest information of the current local computer’s forest.

————————– EXAMPLE 3 ————————–
C:\PS>Get-ADForest -Current LoggedOnUser
Get the forest information of the current logged on users’s forest.

————————– EXAMPLE 4 ————————–
C:\PS>Get-ADForest
ApplicationPartitions : {DC=ForestDnsZones,DC= TOSSolution,DC=com, DC=DomainDnsZones,DC= TOSSolution,DC=com}
CrossForestReferences : {CN=northwind,CN=Partitions,CN=Configuration,DC= TOSSolution,DC=com}
DomainNamingMaster : TOSSolution-DC1. TOSSolution.com
Domains : { TOSSolution.com}
ForestMode : Windows2003Forest
GlobalCatalogs : { TOSSolution-DC1. TOSSolution.com, SCX3254268. TOSSolution.com}
Name : TOSSolution.com
PartitionsContainer : CN=Partitions,CN=Configuration,DC= TOSSolution,DC=com
RootDomain : TOSSolution.com
SchemaMaster : TOSSolution-DC1. TOSSolution.com
Sites : {Default-First-Site-Name, UnitedKingdomHQ, BO3, RODC-Site-Name}
SPNSuffixes : {}
UPNSuffixes : {}
Gets the forest information for the forest of the currently logged on user.

————————– EXAMPLE 5 ————————–
C:\PS>$allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController –Filter * -Server $_ }
Gets a list of all the domain controllers for all domain within a forest.

You can check the Version, CommandType and Source of this cmdlet by giving below command.

Get-Command Get-ADForest

You can also read about
. Set-ADForest
. Set-ADForestMode

To know more PowerShell cmdlets(Commands) on addsadministration (Active Directory) click here

Click on this Link for an Single place where you get all the PowerShell cmdlet sorted based on the modules.

You can also refer other blogs on PowerShell at link

You can also refer other blogs on Microsoft at link

And also if you required any technology you want to learn, let us know below we will publish them in our site http://tossolution.com/

Like our page in Facebook and follow us for New technical information.

References are taken from Microsoft

Exit mobile version