Update Calendar delegation


posted by mpetka
01-29-2013

Downloads: 153
File size: 3.3kB
Views: 862

Embed
Update Calendar delegation
  1. $mbtoDelegate = "manager@yourco.com" 
  2. $delegatetoAdd = "admin@yourco.com" 
  3.  
  4. Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll" 
  5. $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2 
  6. # Create a new Exchange service object  
  7. $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion
  8.  
  9. $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent() 
  10. $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">" 
  11. $aceuser = [ADSI]$sidbind 
  12.  
  13. $service.AutodiscoverUrl($aceuser.mail.ToString()) 
  14. $service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $mbtoDelegate); 
  15.  
  16. $mbMailbox = new-object Microsoft.Exchange.WebServices.Data.Mailbox($mbtoDelegate
  17. $dgUser = new-object Microsoft.Exchange.WebServices.Data.DelegateUser($delegatetoAdd
  18. $dgUser.ViewPrivateItems = $false 
  19. $dgUser.ReceiveCopiesOfMeetingMessages = $true 
  20. $dgUser.Permissions.CalendarFolderPermissionLevel = [Microsoft.Exchange.WebServices.Data.DelegateFolderPermissionLevel]::Editor 
  21. #$dgUser.Permissions.InboxFolderPermissionLevel = [Microsoft.Exchange.WebServices.Data.DelegateFolderPermissionLevel]::None 
  22. $dgArray = new-object Microsoft.Exchange.WebServices.Data.DelegateUser[] 1 
  23. $dgArray[0] = $dgUser 
  24. #$service.AddDelegates($mbMailbox, [Microsoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope]::DelegatesAndMe, $dgArray); 
  25. $service.UpdateDelegates($mbMailbox, [Microsoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope]::DelegatesAndMe, $dgArray); 
Filed under: ,

We update and change delegates on a regular basis for our users. This will allow you to add, remove or update a users calendar delegates

Copyright 2012 PowerShell.com. All rights reserved.