thub.users.profile.tabs.comments.personalized


Thank you for this, but in this script, there's a specific path. The domain A has a similar structure of OU with Domain B. That's why I use replace function on my last script.

so Example

if Domain B has the user John with distinguishedname of CN=JOHN, OU=MigP, OU=Test OU, DC=Lima, DC=net
It will match the user displayname in the Domain A then move it to a the same OU but considering the replace it should be CN=JOHN, OU=MigP, OU=Test, DC=Nbainc, DC=org. --- this should be the target path

("Lima", "NBAinc") -replace ("net", "org") -replace ("Test OU", "Test")


I first get the disitinguished name of the users from DOmain B that has a trust with my current domain $Limausers = (Get-ADUser -Server "$SeverB" -Credential $credential -filter "displayname -like 'sp '" -searchbaseB $searchbase -properties )

My intention is to replace the distinguished properties with my current structure in my domain (A). In which I came up with replace, to use replace it must be converted to a string.

$targetpath= foreach ($Lima in $Limausers) {

$LimaString= $Lima -replace '^.+?(?<!),',''
$path = Out-String -inputobject $LimaString
$path.replace("Lima","NBAinc") -replace ("net","org") -replace ("Test OU","Test")

}
$targetpath

my output should be OU=Users, OU= Test, DC=NBAinc, DC=org
then use that as a target path to my current domain.

Thank you for your answer. What do you suggest on what should I do to make it work? Based on the requirements

Thank you so much!!! it works !!!