Skip to main content

Posts

Showing posts from January, 2013

Using the PidTagAdditionalRenEntryIdsEx property in EWS to access localized folders such as the RSS Feeds folder in EWS and Powershell

As I've covered before in this post when you want to access the WellKnowFolders in EWS in a language independent way (eg not having to worry about localization) you can use the WellKnowFoldersName Enumeration in EWS http://msdn.microsoft.com/en-us/library/exchange/microsoft.exchange.webservices.data.wellknownfoldername%28v=exchg.80%29.aspx . Although most of the folderID's are now included in the enumeration one that is missing is the RSS Feeds folder Id.. The Extended property that holds the PR_EntryID for the RSS Feeds Folder is the PidTagAdditionalRenEntryIdsEx extended property on the Non_IPM_Subtree of a mailbox. This Id is held within a PersistData Block which is a structured Binary property that if you want to read in EWS you need to decode (which is fun). So how do you decode this property the first thing you want to do is convert it to Hex String while you could deal with it in the Binary array I find it easier to deal with as a Hex String. $hexVal = [System.BitCo

Creating a new Calendar,Contacts,Tasks or Notes Sub Folder in EWS with Powershell

I've had a few questions about this in the past week so I thought I would put together a quick sample to show how you can create a new Folder is EWS and set the FolderClass so it appears as a Calendar, Contacts, Tasks, Notes or whatever other folder you want. This is a function so you can just cut and paste it into your own script to use. The full script looks like the following which has samples of using the function at the bottom. ## Get the Mailbox to Access from the 1st commandline argument       $MailboxName  =  $args [0]      ## Load Managed API dll      Add-Type -Path  "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"           ## Set Exchange Version      $ExchangeVersion  = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2          ## Create Exchange Service Object      $service  =  New-Object  Microsoft.Exchange.WebServices.Data.ExchangeService( $ExchangeVersion )          ## Se

Cleaning out the Skeletons in your mailbox by deleting all the Empty folders with EWS and Get-MailboxFolderStatistics

One of the things you may find if your using Archive or Retention policies a lot is that you end up with skeleton folders in your mailbox. Which are basically the old folders trees that are all now empty because the items have been moved to the Archive or aged out of the Mailbox. To see your skeletons you can use the Get-MailboxFolderStatistics cmdlet and something like this to identify user created folders that are empty. get-mailboxfolderstatistics $MailboxName | Where-Object{$_.FolderType -eq "User Created" -band $_.ItemsInFolderAndSubFolders -eq 0} If you want to delete those folders there is no cmdlet to do this so you need to use EWS. Following on from my last post we can take the FolderId from Get-MailboxFolderStatistics convert this Id to a EWSId so we can then bind to the folder in EWS and then delete it using the Delete method. I've put together a sample script to show how to do this by first using the Get-MailboxFolderStatistics and then in EWS ConvertId

Converting FolderId's from Get-MailboxFolderStatistics to use in EWS

If you are using the Exchange Managed Shell Get-MailboxFolderStatistics cmdlet to track down issues or report on folders and you want to be able to get that same folder in EWS to do something else with it here's is script that you can use to do this. This script uses the ConvertId Operation in EWS to convert the OWAId you get from EMS to a EWSId which you can then use in EWS to bind to the folder. ## Get the Mailbox to Access from the 1st commandline argument       $MailboxName = $args[0]     ## Load Managed API dll      Add-Type -Path  "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll"           ## Set Exchange Version      $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2          ## Create Exchange Service Object      $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion)          ## Set Credentials to use two options are availible
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.