troubleshooting Question

Exchange 2010 script help

Avatar of simpleworksit
simpleworksit asked on
ExchangePowershellWindows Server 2008
22 Comments1 Solution831 ViewsLast Modified:
I am trying to write a script that enables online archive and sets a retention policy for users in two mailbox databases and removes online archives and sets a different retention policy for users in another mailbox database.  

I have worked out the commands that I need, I just need some help putting them all together into a script and calling that script from a scheduled task.  I have tested running them from EMS and they work great. I would like some pointers on how to call them in EMS environment instead of regular powershell if possible.  If I run them from Powershell ISE or just powershell with the exchange snapins added, I get a bunch of warnings  Ex. WARNING: The cmdlet extension agent with the index 3 has thrown an exception in OnComplete()  

Here is what I have so far.

Load Exchange Modules/PSSnapins
Get-PSSnapin -Registered | Add-PSSnapin

Set Retention Policy based on Mailbox Database
Get-Mailbox -ResultSize unlimited -Database Tier1 -Filter {(Name -NotLike "DiscoverySearch*")} | Set-Mailbox -RetentionPolicy "6 Month Archive"
Get-Mailbox -ResultSize unlimited -Database Tier2 -Filter {(Name -NotLike "DiscoverySearch*")} | Set-Mailbox -RetentionPolicy "6 Month Archive"
Get-Mailbox -ResultSize unlimited -Database Tier3 -Filter {(Name -NotLike "DiscoverySearch*")} | Set-Mailbox -RetentionPolicy "6 Month Delete"

Enable/Disable Online Archive based on Mailbox Database
Get-Mailbox -ResultSize unlimited -Database Tier1 -Filter {(Name -NotLike "DiscoverySearch*")} | Enable-Mailbox -Archive -ArchiveDatabase Tier1
Get-Mailbox -ResultSize unlimited -Database Tier2 -Filter {(Name -NotLike "DiscoverySearch*")} | Enable-Mailbox -Archive -ArchiveDatabase Tier2
Get-Mailbox -ResultSize unlimited -Database Tier3 | Disable-Mailbox -Archive


Any assistance would be greatly appreciated.  Thanks gentlemen!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 22 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 22 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros