Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Script needed - Remove all server-side forwarding from mailboxes where the AD account is disabled

Posted on 2016-09-08
7
Medium Priority
?
105 Views
Last Modified: 2016-09-13
Current client NEVER removes old mailboxes. All they do is disable the AD account and set the mailbox to be hidden from the GAL.

However, now they are aware that there are a lot of these that still have active autoforwards set to external addresses. Not good.  So they want these rules gone.
0
Comment
Question by:paulfoel
7 Comments
 
LVL 25

Assisted Solution

by:Brian B
Brian B earned 1000 total points
ID: 41790597
Instead of that, why not dump the mailboxes to PST and delete the mailbox? Saves space and you don't have to keep old accounts around.
0
 
LVL 38

Expert Comment

by:Mahesh
ID: 41790606
even if you disable ad account and hide it from GAL, it won't stop receiving new mails on mailbox and since forwarding if removed, it will simply filling space in that mailbox and nobody will see those mails

Better if you delete mailbox as well as suggested above
1
 
LVL 17

Accepted Solution

by:
Todd Nelson earned 1000 total points
ID: 41790607
It's a bit more challenging to do for disabled accounts but you stated the accounts are disabled and the mailbox hidden from the address lists.  In that case, lets target those mailboxes that are hidden from the address lists.

For all mailboxes with the HiddenFromAddressListsEnabled parameter set to true, we will disable all forwarding like this...

Get-Mailbox -ResultSize Unlimited | Where { $_.HiddenFromAddressListsEnabled -eq $true } | Set-Mailbox -DeliverToMailboxAndForward $false -ForwardingSmtpAddress $null -ForwardingAddress $null

Open in new window

If you want to do it for a list of users in a CSV file (with DisabledUser as a header), we will do it like this...

Import-CSV "DisabledUsers.csv" | foreach-object { Get-Mailbox -Identity $_.DisabledUser | Set-Mailbox -DeliverToMailboxAndForward $false -ForwardingSmtpAddress $null -ForwardingAddress $null }

Open in new window


Hope this helps.
2
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
LVL 1

Author Comment

by:paulfoel
ID: 41790808
Thanks all. Yes it would be easier to remove the old accounts of course. BUT its up to my client not me to decide this - I just advise lol.
0
 
LVL 25

Expert Comment

by:Brian B
ID: 41791283
Paul, thanks for getting back to us and accepting the question. Just wanted to ask though why you accepted Mahesh's answer when all he did was agree with me?
0
 
LVL 1

Author Comment

by:paulfoel
ID: 41793829
Brian - my mistake. Your right. I will amend.
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question