Solved

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

Posted on 2016-09-08
7
68 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 23

Assisted Solution

by:Brian B
Brian B earned 250 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 35

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 14

Accepted Solution

by:
Todd Nelson earned 250 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
Are your corporate email signatures appalling?

Is it scary how unprofessional your email signatures look? Do users create their own terrible designs and give themselves stupid job titles? You can make this a lot easier for yourself by choosing an email signature management solution from Exclaimer today.

 

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 23

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
 

Author Comment

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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now