I am trying to accomplish anyone has ForwardingAddress in TermedEmployees OU, remove the ForwardingAddress with powershell.
When I run the following command, I get "couldn't find organizational unit. "
Get-Mailbox -organizationalUnit "test.edu\People\TermedEmployees" -ResultSize unlimited | Where
{$_.ForwardingAddress -ne $null} | Set-Mailbox -ForwardingAddress $null -DeliverToMailboxAndForward $false
I created csv file which contains all users in TermedEmployees OU and saved as termempdata.csv and tried to remove Forwarding from there, but this doesn't eliminate Forwarding rule, either.
$users = import-csv c:\outlookdata\termempdata.csv
$users | % { get-mailbox $_.UserPrincipalName | Where {$_.ForwardingAddress -ne $null} | Set-Mailbox $._UserPrincipalName -ForwardingsmtpAddress $null -DeliverToMailboxAndForward $False}
I don't get an error, but it looks like Set-Mailbox is not working at all.
Thanks.
Akiko