[Outlook] Use PowerShell to does delegates like Outlook.

Source: Internet
Author: User

Environment:exchange SP2 + Outlook 2010

Adding delegate is actually not the easy I thought, at least no just one command to complete everything, this is because Many additional actions are performed by Outlook client, command on server actually is one of the them.

Below is a typical settings screenshot from Outlook, you can see I highlighted those permission items.

1. Editor permission of Calendar

2. Editor permission of Tasks

3. "Delegate receives copies of meeting-related messages sent to me" would be ticked

Things already like this in old Outlook 2003 client, but the additional permissions/options complete by Outlook cause a PR Oblem, we need to does mutliple steps from server with many commands.

In Exchange, the cmdlet set-mailbox-grantsendonbehalfto can is used to grant delegate, Add-mailboxfolderpermission C Mdlet can used to the grant folder permissions like Calendar and Tasks. Problem is on the option ' Delegate receives copies of meeting-related messages sent to me ', there is no directly cmdlet CA n Enable this option, anyhow this option was quite necessaried by assistants.

To solve the problem, since normal cmdlets can ' t being used, EWS (Exchagne Web service) is needed, actually outlook is also u Se EWS to do the same.

First, we need download EWS API from Microsoft.

EWS api-http://www.microsoft.com/en-us/download/details.aspx?id=35371

can choose to install or just extract what we need from the installer with 7-zip instead, all we need are "microsoft.ex Change. WebServices.dll ".

Open the PowerShell, use Import-module to import the binary DLL, so the classes can is used by us, of course [Reflection.a Ssembly]::loadfile () can do the same.

Import-module. \microsoft.exchange.webservices.dll

Below command Create a Exchangeservice instance from the class, if don ' t specify Exchange version, the instance would use T He latest version in API by default.

$Service = New-object Microsoft.Exchange.WebServices.Data.ExchangeService (' exchange2010_sp2 ')

User $Service can show some properties, method can be retrieved by Get-member cmdlets, too many of them I won ' t paste here.

Now, we need to specify the URL of EWS, or use Autodiscover function of Exchange, I recommand Autodiscover function, Becau Se It reads settings of Autodiscover directly from Active Directory, as long as Outlook works fine, the function must Runn ing well too.

$Service. Autodiscoverurl (' [email protected] ')

Or, specify EWS URL like below

$Service. Url = ' Https://CASServer/ews/exchange.asmx '

Dategates related methods can be known from $Service | Get-member

Adddelegatesgetdelegatesremovedelegatesupdatedelegates

Obviously, Adddalegates is the one, $Service. Adddelegates can output its paramembers,

Parameter 1 is a mailbox, which are the target MailboxMicrosoft.Exchange.WebServices.Data.Mailbox Mailboxparameter 2 is a M EetingRequestsDeliveryScopeMicrosoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope Meetingrequestsdeliveryscopeparameter 3 is a delegateusers CollectionMicrosoft.Exchange.WebServices.Data.DelegateUser

Parameter 2, you can see it from below Outlook screenshot,

Now we have the method, parameters, including parameter types, generate them now.

Parameter 1,

$Mailbox = New-object Microsoft.Exchange.WebServices.Data.Mailbox (' [email protected] ')

Parameter 2,

$Scope = [Microsoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope]::D elegatesonly

Parameter 3,

$dgUser = New-object Microsoft.Exchange.WebServices.Data.DelegateUser (' [email protected]yyy.com ') $ DgUser.Permissions.CalendarFolderPermissionLevel = ' editor ' $dgUser. Permissions.tasksfolderpermissionlevel = ' editor ' $dgUser. Receivecopiesofmeetingmessages = $true  

All right, parameters filled, use Adddelegates method to apply it.

$Service. Adddelegates ($Mailbox, $Scope, $dgUser)

There'll is no errors if every step runs well, the method would return running result, even if failed we can still know W Hy failure.

[Outlook] Use PowerShell to does delegates like Outlook.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.