list of Outlook calendar folders

Welcome Forums General PowerShell Q&A list of Outlook calendar folders

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 7 months ago.

  • Author
  • #5455

    Topics: 1562
    Replies: 0
    Points: 0
    Rank: Member

    by Darth_Vodka at 2013-01-21 09:09:31


    I have an Outlook mailbox and in there are two calendars

    I have some powershell script that pull the appointments into a CSV file and it works fine, but it doesn't get the appointments from the new secondary calendar

    So, does anyone have any PS script to list the calendar names or to access non-default calendars?

    thanks in advance

    by nohandle at 2013-01-22 00:39:05

    how does the script looks like? Does it work via Outlook interop (COM object)?

    by Darth_Vodka at 2013-01-22 01:09:12


    the script looks like this, below

    it doesn't use interop, but I have no objection to using anything

    $startdate = "18 January 2013 00:00:00"
    $EndDate = "18 January 2013 23:59:59"

    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)

    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://"
    $aceuser = [ADSI]$sidbind


    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$MailboxName)
    $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderid)
    $cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate)
    $cvCalendarview.PropertySet = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
    $frCalendarResult = $CalendarFolder.FindAppointments($cvCalendarview)
    foreach ($apApointment in $frCalendarResult.Items)

    by nohandle at 2013-01-22 04:08:38

    EWS managed API then 🙂 what kind of calendars you need to access? Some you created? Some from archive? Calendars of other people?
    Exchange Web Services connects to exchange server so only the data that are presemt there can be accessed (.pst imported to outlook cannot). The calendars you created are saved as folders in the 'wellknown' Calendar folder. I haven't experimented with this much (yet?:) ) but I think you just need to change your scripts logic to search through all the folders that are sub the Calendar root.
    Not sure if it is possible to ask the find appontments method to go recursively but it definitely is possible to list all the folders and go through them yourself.
    To connect to others' calendars you need to bind to another 'mailbox'. To acces the archives I am afraid your only choice is the Outlook interop:/

    by Darth_Vodka at 2013-01-22 04:32:32


    It's not a permissions thing. The calendars I need to access are actually for other people, but for the sake argument, it could be my own mailbox (and defintely not archived stuff) I can see the mailbox and can pull all the appointments I need from the default calendar

    It's the fact that there is a seond calendar that the script doesn't currently see that's the issue

    Like you say, it's probably WellKnownFolderName]::Calendar

    that needs to be changed to get the second calendar...

    by nohandle at 2013-01-22 06:22:10

    I am not sure if we understood each other, I am not talking about permissions anywhere. There are three different scenarios and each needs different approach:
    1) Imported .pst to outlook – use Outlook interop to access the data
    2) Calendar of another user: $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]]$MailboxName[/b])
    $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]]Bind[/b]($service,$folderid)

    You need to bind to another Mailbox name and search the Calendar folder there.

    3)You created more than one calendars: the You need to use FindFolder method to find the correct folder and then use the FindAppointments method to retrieve the correct data. Or maybe there is way to go through the Calendar folder recursively to find all of the items in it using another FolderView or CalendarView restriction.

    Are you familiar with the EWS a bit or is the script downloaded?

    by Darth_Vodka at 2013-01-22 07:39:55


    (thanks for all this btw)

    it's option 3 – I have more than one calendar, I want to refer to it explicitly in powershell. I know its name, I can see it in Outlook

    and no, not familiar with EWS or powershell, the script is a hand-me-down, I think it was off the internet and tinkered with

    will try and get the FindFolder method working

    by nohandle at 2013-01-23 04:39:13

    You are welcome. Find folders method: ... v=exchg.80).aspx
    you call it on the $service object and specify the wellKnown calendar and and folderView – you need to create one using and specify correct arguments to its constructor.
    For example like this new-object Microsoft.Exchange.WebServices.Data.FolderView (1000)

    by Darth_Vodka at 2013-01-24 07:22:48

    right, i've got something that works for non-default calendar folders

    it's probably not written in the greatest of ways...but hey ho, it works, got it in part from the advice here, some notes on and the legacy code

    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"

    Function FolderCode([string]$MailBoxName, [string]$PathToSearch)

    $startdate = "18 January 2013 00:00:00"
    $EndDate = "18 January 2013 23:59:59"
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://"
    $aceuser = [ADSI]$sidbind

    #Connect to Exchange as the current user
    $WindowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $SidBind = "LDAP://"
    $AceUser = [ADSI]$SidBind

    #Bind to the MSGFolder Root
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$mailboxname)
    $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)

    #Perform search based on the displayname of each folder level
    $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
    $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$PathToSearch)

    $findFolderResults = $service.FindFolders($tfTargetFolder.Id,$SfSearchFilter,$fvFolderView)
    foreach($folder in $findFolderResults.Folders){
    $cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate)
    $frCalendarResult = $folder.FindAppointments($cvCalendarview)
    foreach ($apApointment in $frCalendarResult.Items)
    FolderCode "" "Fitter"
    FolderCode "" "Calendar"

    hope that helps somebody else thinking about the same problem

    by sunnyc7 at 2013-01-24 07:53:06

    Please check this post by Jan Egil Ring. ... shell.aspx

    I'd think, this gives you a better control over your calendar items, than the Glenn Scales script, as it populates the ID field.
    You can iterate over ID, and then do your exports.

The topic ‘list of Outlook calendar folders’ is closed to new replies.