Solved

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

Posted on 2016-09-08
7
63 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

760 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

18 Experts available now in Live!

Get 1:1 Help Now