1. Launch Powershell cmd prompt from the programs menu.
  2. Inside the cmd prompt , type Get-ADTrust
  3. if it fails – do this first : import-module activedirectory

Once you have the module, you should be able to run all AD commands. This should show you all the currently trusted domains on this DC.

  • If the required DC does not show up, try to create a new trust using the PS script below.

Create New Trust

# Change following parameters 

$strRemoteForest = "forestName1.something"

$strRemoteAdmin = "adminAccountName"

$strRemoteAdminPassword = "Heslo@123"

$remoteContext = New-Object -TypeName"System.DirectoryServices.ActiveDirectory.DirectoryContext" -ArgumentList @( "Forest",$strRemoteForest, $strRemoteAdmin, $strRemoteAdminPassword)

try {

$remoteForest =[System.DirectoryServices.ActiveDirectory.Forest]::getForest($remoteContext)

#Write-Host "GetRemoteForest: Succeeded for domain $($remoteForest)"

}

catch {

Write-Warning "GetRemoteForest: Failed:`n`tError: $($($_.Exception).Message)"

}

Write-Host "Connected to Remote forest: $($remoteForest.Name)"

$localforest=[System.DirectoryServices.ActiveDirectory.Forest]::getCurrentForest()

Write-Host "Connected to Local forest: $($localforest.Name)"

try {

$localForest.CreateTrustRelationship($remoteForest,"Inbound")

Write-Host "CreateTrustRelationship: Succeeded for domain $($remoteForest)"

}

catch {

Write-Warning "CreateTrustRelationship: Failed for domain$($remoteForest)`n`tError: $($($_.Exception).Message)"

}

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.