I am trying to write a script that would first get an attribute from AD based on an email address from a list and populate an attribute in another forest with that same value retrieved from the first domain.
**********************************
#Get email addresses from the list
$eadd = GetContenct "C:\t6\names.txt"
#Get the mailNickName from the user's attribute using the email address to find the user
$mnn = Get-ADUser -Filter * -Properties Name,mailNickname,mail -SearchBase "OU=Users,OU=Wherever,OU=mycompany,dc=us,dc=domain1,dc=com" -Server "us_servername.domain1.com" | where {$_.mail -eq $eadd} | Select mailNickname
#Enter the mailNickName attribute value from domain 1 with the same email address into domain 2 mailNickName attribute
Set-ADUser -Instance $eadd -Server "otherserver.domain2.com" -Replace @{mailNickName="variable retrived from above($mnn)"}
***************************************
Need to get the proper format for the variable $mnn into the set command so it uses the value I get from the Get command properly.
I am still learning Powershell so maybe I am over engineering this. Just not sure how to pass the mailNickname value I got from the first domain to the set-aduser command to set the value in the second domain.
Thanks in advance for you help.
Dave