Scripting Agent for Calendar Permissions
-
Tuesday, March 13, 2012 9:41 AM
Hi,
I am trying to get new mailboxes to have permissions altered on their calendar
folders. I understand I need to use the scripting agent, and a script called ScriptingAgentConfig.xml I have created this file in the correct place, and ran the command Enable-CmdletExtensionAgent "Scripting Agent".Inside the xml file is as below, I have tried both “new-mailbox” and “enable-mailbox” and “MailboxProvisioning” and “MailboxProvisioningDatabase” nothing I do can seem to get this to work. I don’t know PowerShell very well either which doesn’t help, but I tried to get the $NewMailbox variable written to a file by using $NewMailbox > c:\output\test.txt and that didn’t seem to produce anything either, so it makes me wonder if it’s even getting as far as the command I want to execute.
<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
$newmailbox = $provisioningHandler.UserSpecifiedParameters["Name"]
Add-MailboxFolderPermission -Identity $newmailbox + ":\Calendar" -User "Steve" -AccessRights Editor
}
</ApiCall>
</Feature>
</Configuration>
Any help is much appreciated. Thanks
All Replies
-
Thursday, March 15, 2012 3:54 AMModerator
-
Friday, March 16, 2012 9:48 AM
Hi,
This hasnt seemed to have worked either. when i use Disable-CmdletExtensionAgent "Scripting Agent" I am asked to confirm if i want to disable the scripting agent, but when i use Enable-CmdletExtensionAgent "Scripting Agent" to enable it in the first place i dont get any feedback, it simply goes back to the command line ready for input. I am not 100% sure if the scripting agent is enabled anyway, is there a way i can check its state?
-
Friday, March 16, 2012 9:54 AMIm no use at Powershell but I'm not as daft as I thought I was. Get-CmdletExtensionAgent returns all the agents and thier state, it does show that the scripting agent is enabled..... so something is wrong with this. Any way I can "step through" this xml file can you can when you debug programming languages. I dont know enough about Powershell.
-
Friday, March 16, 2012 10:15 AM
Also, after i created the mailbox i ran Get-MailboxFolderPermission -Identity user.name:\Calendar
but it didnt show the user had any rights applied. this is why i am thinking it doesnt work, surely the user shouldnt have to log into the mailbox first for the rights to be assigned do they?
-
Monday, March 19, 2012 7:08 AMModerator
after i created the mailbox i ran Get-MailboxFolderPermission -Identity user.name:\Calendar
but it didnt show the user had any rights applied. this is why i am thinking it doesnt work, surely the user shouldnt have to log into the mailbox first for the rights to be assigned do they?
Hi Steve,
Do you mean you get nothing after you run the cmdlet?
If you disable the agent then create a new mailbox, what's the permission on the Calendar folder?
By default, the permission should be:
Default AvailabilityOny
Anonymous None
If possible, please reopen EMC and EMS after you change the state of the agent to test.
By the way, it works in my test lab(Exchange 2010 SP2 ru1).
Please check the steps as following blog lists:
Using Cmdlet Extension Agents to cause automatic events to occur in Exchange 2010 – life just got simpler!
Frank Wang
TechNet Community Support
-
Wednesday, March 21, 2012 1:46 AMModerator
-
Wednesday, March 21, 2012 11:34 AM
Hi, sorry for the delay in moving forwards with this, ive currently got like a million and one issues to fix with various things. i will update the moment i get a chance. thank you for your replies, i might just end up building a test box with exchange on it and seeing if this will work straight off the bat, if not then obviously something is a miss there.
thanks
-
Tuesday, March 27, 2012 1:49 AMModerator
-
Wednesday, March 28, 2012 1:35 PM
When a new mailbox is created the calendar has the default permissions applied which you described above. I followed that link in the first place to initially set it up and my results were that it didnt work.
I will create a blank new test server for this, but I'm afraid it wont be until sometime in May due to other work pressures. Id like to keep this post open until I resume back to it in May
thanks
Steve
-
Tuesday, May 01, 2012 11:21 AMI have just built a fresh installation in a test lab, running this code still does not work the new mailbox only has its default accessrights applied. any further suggestions? i am quite sure if someone uses the exact code i have there it wont work....
-
Wednesday, May 16, 2012 2:32 PMI have recently installed SP2 for exchange, the scrpt now functions as it should do. However, when a user is created using the SBS Console it doesnt work, SBS must use another command to make the mailbox, i tried both New-Mailbox and Enable-Mailbox but neither seem to work when creating a users mailbox using the SBS console. i will post this question in the SBS forums
-
Wednesday, October 17, 2012 8:02 AM
Hi Steve
I'm attempting to do the same thing with our Exchange 2010 system but can't work out exectly what code you used to get this working. Could you please put the working code here.
Thanks
Nick
-
Wednesday, October 17, 2012 9:47 AM
Hi Nick,
I never actually got this working for SBS 2011, but it does work for a standard windows server with exchange 2010, please see a copy of my documented process to accomplish this below:
Create the following XML file and save it as ScriptingAgentConfig.xml in the folder C:\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents
<?xml version="1.0" encoding="utf-8" ?> <Configuration version="1.0"> <Feature Name="MailboxProvisioning" Cmdlets="New-Mailbox"> <ApiCall Name="OnComplete"> if($succeeded) { $newmailbox= $provisioningHandler.UserSpecifiedParameters["Name"] Add-MailboxFolderPermission -Identity $newmailbox":\Calendar" -User "Calendar Editors" -AccessRights Editor Add-MailboxFolderPermission -Identity $newmailbox":\Calendar" -User "Company Viewers" -AccessRights Reviewer } </ApiCall> </Feature> <Feature Name="MailboxProvisioning" Cmdlets="Enable-Mailbox"> <ApiCall Name="OnComplete"> if($succeeded) { $Id = $provisioningHandler.UserSpecifiedParameters["Identity"].ToString() Add-MailboxFolderPermission -Identity $newmailbox":\Calendar" -User "Calendar Editors" -AccessRights Editor Add-MailboxFolderPermission -Identity $newmailbox":\Calendar" -User "Company Viewers" -AccessRights Reviewer } </ApiCall> </Feature> </Configuration>
Then, enable the scripting agent for Exchange 2010:
- Open Exchange Management Shell
- Run the command
Enable-CmdletExtensionAgent "Scripting Agent"
You can verify the Calendar permissions on any particular mailbox by running the following command
Note that you must have the security groups "Calendar Editors" and "Company Viewers" created in AD (or create the names of groups to that of your own choice.
I hope this helps, but like I said if you are trying this with SBS 2011 using the SBS Console this doesn't seem to work, even though apparently it uses the "enable-mailbox" bit.

