S
S
Sergey2015-03-23 13:32:25
PowerShell
Sergey, 2015-03-23 13:32:25

How to mass create mailboxes and set up forwarding for all?

Colleagues.
There is a domain: @blabla.ru
And there are users: [email protected]
I'm trying to create mailboxes for all users.

Get-User -OrganizationalUnit "IT" -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | Enable-Mailbox

But! I need all mail coming to these addresses to be redirected to another server with a different domain.
That is, forward all mail coming to [email protected]-> to [email protected]
Usernames are the same there and there, only the domains are different.
Question: How can I do this without manually editing each box?
Set-Mailbox -Identity "user" -ForwardingAddress "[email protected]"

That is, in my understanding it should be something like this:
Get-User -OrganizationalUnit "IT" -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | Enable-Mailbox | Set-Mailbox -ForwardingAddress ?????

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nikitin, 2015-03-23
@padla2k

Enable-MailBox unfortunately has no output parameters. Therefore, you will have to do your activities in two stages.
1. Enable all boxes:
2. Enable redirection for them:

Get-User -OrganizationalUnit "IT" -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | %{$forwardedEmail = "{0}@bleble.ru" -f $_.SamAccountName; Set-Mailbox -ForwardingAddress $forwardedEmail}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question