This arctical'll be is published in 中文版 also-http://www.cnblogs.com/larryatcnblog/p/4062593.html
Environment Exchange SP2 + Outlook 2010
Adding delegate is not really a command, because with command-line operations on the server and Outlook local operations are completely different, Outlook automatically does a number of other things, such as the default in Outlook to check a few features.
1. Editor Permissions for Calendar
2. Editor Permissions for tasks
3. Delegate receives copies of meeting-related messages sent to me will tick
This is actually true in outlook2003, but this leads to a problem in Exchange 2010, although a SET-MAILBOX-GRANTSENDONBEHALFTO is provided to add delegate, But this is just a delegate, there are no options in the default settings at all, so there are some other commands to do.
1. Calendar and tasks can use Add-mailboxfolderpermission to add permissions.
2. The problem is that "Delegate receives copies of meeting-related messages sent to me", this feature is a lot of assistant, but only it does not have a cmdlet can be directly modified.
So, here's how to use EWS (Exchange Web Service) to make a complete delegate, which is actually done by Outlook.
First step, download EWS api-http://www.microsoft.com/en-us/download/details.aspx?id=35371
Ann does not install does not matter, we only need to use the inside of the Microsoft.Exchange.WebServices.dll, with 7z can actually extract out to skip installation.
Then open PowerShell, and with the webservice, it doesn't matter where the PowerShell runs.
Using Import-module to boot the DLL, its class can be used by us, of course, if you like the tall code, you can also use the [Reflection.assembly]::loadfile () method.
Import-module. \microsoft.exchange.webservices.dll
Run the following code to build a Exchangeservice instance, if there is no subsequent exchange2010_sp2, the instance will default to the latest build in the API.
$Service = New-object Microsoft.Exchange.WebServices.Data.ExchangeService (' exchange2010_sp2 ')
Then input $service can see some properties, or use Get-member also can get method, here I don't post out.
In this case, you need to specify the URL of EWS, there are two ways, one is to directly specify the URL of EWS, or with $service a method called Autodiscoverurl automatic discovery, the individual is recommended Autodiscoverurl, Because this is the configuration that reads the Autodiscover directly from the ad, as long as Outlook can discover normally, then this function is sure to be OK.
$Service. Autodiscoverurl (' [email protected] ')
or specify EWS directly on the CAS server as below
$Service. URL = ' Https://CASServer/ews/exchange.asmx '
From the $service method, you can see the methods associated with delegate ($Service | get-member)
Adddelegatesgetdelegatesremovedelegatesupdatedelegates
Still very obvious, with Adddelegates can add delegate, use $service.adddelegates can directly output it received several parameters, the output may be a bit chaotic, clean up as follows,
Parameter 1 is a Mailbox, which is our goal MailboxMicrosoft.Exchange.WebServices.Data.Mailbox Mailbox Parameter 2 is a meetingRequestsDeliveryScopeMicrosoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope Meetingrequestsdeliveryscope Parameter 3 is a collection of Delegateusers Microsoft.Exchange.WebServices.Data.DelegateUser
Where parameter 2 is the setting in Outlook,
Now that the method has, the parameter also knows, the parameter type also has, then each one produces them to be good.
Generate Parameter 1,
$Mailbox = New-object Microsoft.Exchange.WebServices.Data.Mailbox (' [email protected] ')
Generate Parameter 2,
$Scope = [Microsoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope]::D elegatesonly
Generate Parameter 3,
$dgUser = New-object Microsoft.Exchange.WebServices.Data.DelegateUser (' [email protected]yyy.com ') $dgUser. Permissions.calendarfolderpermissionlevel = ' editor '$dgUser. Permissions.tasksfolderpermissionlevel = ' editor '$dgUser$true
OK, 3 parameters completed, the following is called Adddelegates put delegates plus go.
$Service. Adddelegates ($Mailbox$Scope$dgUser)
Running correctly is not an error, but may fail, the return of this method is the execution result, if the error will also include the specific error message is very good troubleshooting.
[Outlook] uses PowerShell to do delegate in Outlook.