Exchange Server Scripting Agent

Recently I had to set default calendar permissions for all the users in our Exchange Organization.

This is easily done by a simple oneliner (or in this case “two-liner”):

Get-Mailbox -ResultSize Unlimited |
Set-MailboxFolderPermission -Identity "$($_.SamAccountName):\Calendar" -User "Default" -AccessRights "LimitedDetails"

This command will, of course, only set the permissions for existing mailboxes. New mailboxes created either with New-Mailbox or Enable-Mailbox will still have a different default setting. In researching how to perform this for all future mailboxes, I came accross the Exchange Scripting Agent (which, honestly, I should have discovered a long time ago!).

Simply put, the scripting agent enables you to perform a certain process, after a given cmdlet is run. Read this post for more information on the subject (Technet blogpost).

I just needed the calendar bit, so this is my xml file on github (copied from technet blogpost and edited to suit my requirements). I tried experimenting to remove the Start-Sleep, but could not get rid of an intermittent error with “Get-MailboxFolderStatistics” without the 20 second delay. If you want to use this xml, just replace with your domain fqdn.

Make sure this file is copied to all Exchange Servers (also after editing). Exchange does not replicate this file.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.