I am trying to do something like this:
for each mailbox in $OU
Find its matching contact in $OU2 - set mailbox forwarding of mailbox to its matching contact
I have tried to do the following but it doesnt work....
# Unhides all mail contacts in OU2, sets all mailboxes in OU1 to its matching contact in OU2
$orgu2
= ''
$orgu1
= ''
get-mailcontact
-OrganizationalUnit $orgu2 |Set-Mailcontact -HiddenFromAddressListsEnabled $false
Get-User
-OrganizationalUnit $orgu1 -RecipientTypeDetails UserMailbox | Foreach-Object{
$contact2
= (get-contact $_.Name -OrganizationalUnit $orgu2 ).DistinguishedName
$_
|Get-Mailbox| Set-Mailbox -ForwardingAddress $contact2 -DeliverToMailboxAndForward $false}