Creating a two-way Forest trust with Powershell

Posted by Michel Klomp on Geeks with Blogs See other posts from Geeks with Blogs or by Michel Klomp
Published on Tue, 15 Mar 2011 14:44:07 GMT Indexed on 2011/03/15 16:11 UTC
Read the original article Hit count: 416

Filed under:

Here is a small Powershell script for creating a two-way forest trust.

$localforest = [System.DirectoryServices.ActiveDirectory.Forest]::getCurrentForest()
$strRemoteForest = ‘domain.local’
$strRemoteUser = ‘administrator’
$strRemotePassword = ‘P@ssw0rd’
$remoteContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext(‘Forest’, $strRemoteForest,$strRemoteUser,$strRemotePassword)
$remoteForest = [System.DirectoryServices.ActiveDirectory.Forest]::getForest($remoteContext)
$localForest.CreateTrustRelationship($remoteForest,’Bidirectional’)

© Geeks with Blogs or respective owner