It's a problem I was posed with a little while back. Two domains in separate forests, with a full two way trust in place but how do we get a constantly up to date contact list of users in the "Other" forest?
So I set about writing a PowerShell script that would allow me to extract all the users in the "Other" domain and create a mail enabled contact in my domain.
It was decided that each contact would display as "Contact Name (Other Domain)" for clarity when looking through the GAL.
The script creates the Contacts in the OU you specify and updates their key data such as phone numbers, office, job Title, company name, department.
I present below the script I ended up with. It works for me and for a few others who have adopted it. Feel free to use it yourself if you find it useful.
To use the script you will need to edit the section of the script headed "# Changes need to be made to all of the following #"
You will need to set the following:
- $TargetForest - YOUR Domain Name
- $TargetOU - Where to create your new contacts
- $TargetDC - The FQDN of YOUR DC
- $TargetContactSuffix - A Suffix string to apply to all contacts
And for the Remote Domain....
- $SourceForest - REMOTE Domain name
- $SourceDC - FQDN of a DC in $SourceForest
- $SourceOU - Base OU to read users from the remote Domain
Finally the last thing you will need to do is to install the Quest QAD CommandLets (Available Here)
If you manage to enhance/improve it then please, let us all know.
The first enhancement I shall be working on myself is to add the facility for the script to delete contacts that you have for the remote domain where the user can no longer be found on the remote domain.
by: TheCleaner on 2012-03-28 at 08:38:41ID: 47689
This works fantastic, except for one thing. Is there a way to prevent the target forest from creating an SMTP address for the users in the target domain?
Example:
Bob@SourceForest.com email address gets created
Bob@TargetForest.com also gets created but set to secondary address
Or does it even matter? It doesn't appear that it has affected anything but I didn't know if that would cause any issues or not.
Also, in the future if I wish to use federation can I simply delete the contacts before federating?