Disable & Enable Organizations in Exchange 2010 SP1 multi-tenant
One thing I have noticed while working with Exchange 2010 SP1 installed in hosting (or multi-tenant) mode is the lack of the possibility to disable/enable a tenant organization.
There is a lot of scenarios when disabling a tenant organization can be very handy and useful. For example if a client didn't pay, you might want to suspend his account without deleting the whole organization and making him lose data.
I have recently developed my own scripts to disable and enable, or suspend and resume, a specific organization for a client of mine and never thought of sharing them until yesterday when this same question popped up on the technet forum and I thought that they might be helpful for some of you so here they are.
Disclaimer
I need to start with a disclaimer, I have built these script for my own use so they are not polished and might be lacking a lot of features and surely have some bugs. Although I am ready to work on them and enhance them if they find interest and feedback I am not to be held responsible for any damage they might cause to your environment. So, in short,
THE SCRIPTS ARE PROVIDED FREE OF CHARGE AND "AS IS" WITHOUT WARRANTY OF ANY KIND, AND MAY NOT BE ERROR FREE. ANTOINE KHATER, THE AUTHOR OF THESE SCRIPTS, DISCLAIM ALL WARRANTIES AND LIABILITY FOR ANY KIND OF DAMAGES AND/OR LOSS.
Hub Transport Rule based on recipient’s domain
If you have played long enough with Hub Transport rules in Microsoft Exchange 2007 you might have noticed that they contain no flexible condition that applies on the recipient's address.
For whatever reason it is always assumed that the recipient is a user inside your organization and you won't find an easy way to implement the missed ToAddressContains predicate.
In this example I will show you how to build your own ToAddressContains predicate and create a Hub Transport Rule that will Blind Carbon Copy all emails sent to @domain.com to a specific mailbox, this mailbox will be called Alerts.
Microsoft Exchange 2007 up to SP1 Rollup update 8
If you are running any version of Exchange 2007 up to SP1 Rollup 8 create your transport rule by running the following from Exchange Management Shell.
Of course make sure to replace @domain.com and Alerts with the required values.
How to run Exchange .ps1 script as scheduled task
There are many reasons why one would like to run an Exchange powershell .ps1 script as a scheduled task.
In this post I will share with you how to achieve this on both Microsoft Exchange 2007 and Exchange 2010.
Obviously you should start by creating your .ps1 script for this article we will assume the script location is c:\pcs\YourScript.ps1
Managing spaces in AddReplicaToPFRecursive.ps1 script
If you are familiar with Microsoft Exchange 2007 you already know about the AddReplicaToPFRecursive.ps1 script that can be found in the "X:\Program Files\Microsoft\Exchange Server\Scripts", however this script has a bug it doesn't look to support public folders which names contains spaces.
It is quite common to enclose parameters that contains spaces with "quotations" but that doesn't work here.
If you simply try to use the following it will fail.
AddReplicatoPFRecursive.ps1 -TopPublicFolder “\PublicFolder with space” -ServerToAdd “servername”
The solution turned out to be to use single quotes inside the double quotes so it should be something like
AddReplicatoPFRecursive.ps1 -TopPublicFolder “'\PublicFolder with space'” -ServerToAdd “servername”
That's really weird and not standard but it works !

