Thursday, March 01, 2007

Powershell form for Reporting on all Appointments in all mailboxes on a Server using WebDAV

This is another script that's similar to the last few that I've posted in that its designed to query all the mailboxes on a given server and then report the information it finds. The way this script differs is that firstly its a powershell script and secondly it creates a little Winform gui to allow you to interact with the results of the query so its no longer just a static report. The layout it reports back in is two Listviews the first list view shows a summary of the number of appointments the WebDAV query finds for each mailbox and the second is activated when you click a row in the first list view which then shows a list of the appointments in the calendar of the mailbox selected. To make this a little more useful I've added a bunch of filtering options across the top so you can take the original data captured in the appointment query and filter it in a few different ways. Eg you can filter it by the last modified date so you could answer a question such as

Show me all the appointments that where modified after a certain date Or
Show me all the appointments that where modified before a certain date

The two other filtering options are for Free/Busy so you can show all the appointments that are set to free in the time period or all the appointments that aren't set to free. the last filter option is for the Time Zone Mapi property that Matt Stehle blogged about the other day this should show you all the appointments that the rebasing tool has been run on and any that it hasn't. You can combine multiple filters so you could show the number of appointments that where modified after a certain date by the rebasing tool etc.

The Script uses WebDAV via the Admin virtual root directory to access the user calendars this gets around the need for the user running the script to have rights in the users mailbox and should be able to be run successfully using just delegated Exchange Admin rights. To work out the correct path to use for the Admin virtual root the script includes a LDAP query that gets the default SMTP FQDN from the default recipient policy.
By default the script isn’t using SSL which may mean you need to adjust the following line if you are using SSL on the ExAdmin Directory
Eg change line 162
$arMbRoot = "http://" + $snServerNameDrop.SelectedItem.ToString() + "/exadmin/admin/" + $dfAddress + "/mbx/"


$arMbRoot = "https://" + $snServerNameDrop.SelectedItem.ToString() + "/exadmin/admin/" + $dfAddress + "/mbx/"

The script works by querying appointments and then filling a datatable the filtering options work by filtering the data in the datatable using Table selects built by examining the state of different controls and repopulating that data in the listviews I've taken the complete automation approach with this script so there are no command line parameters or servername variables to fill out. When the script runs it will populate the servername list box with the name of all the Exchange servers it finds by querying the configuration partition of the domain its being run in. When you use the script itself you only need to hit the get-appointment button once. After you hit the button in the background the script will attempt to get the appointments for the server you select this can be a lengthy operation to give some progress the script writes back to the console windows as it processes each mailbox. So you may want to push the form to one side and what the status of the powershell console window as it processes each mailbox. When you want to re-filter the data using the filtering options make sure you hit the filter button to filter the data and not the get-appointment buttons. The filter button will re-filter the data in a matter of seconds while the get-appointments but will re-query all the appointments which will take a considerable amount of time. If you want to query other times outside of the DST affected ones you can with this script using the datetime pickers for start and end time..
I've put a downloadable copy of the script here the script itself blew out to over 500 lines so its a little two large to post.


HectorITNT said...


Hope you and the family are doing well.

I have a request to place conference room calendars on a single 40" screen and I remembered seeing this script you have.

I figure I can fit 6 calendars at a time and then switch betweens views and use it as a refresh, keeping always .5 hour before and up to 4 hours future. This calendars are PF based on 2003.
Any advice?


Hector Hernandez

Glen said...

This method should work okay the only thing with PF calendar is there is no freebusy time but it probably not important.If you want to improve performance you might want to look at a script that pulls the calendar appointments from Exchange and puts the result in a XML file. Then you display apps can just read the XML file instead of querying exchange each time.


hectoritnt said...

Do you know how to change the view so that when I call "http://servername/public/folder name" on a calendar type PF it will show me starting at 7:30 AM instead of 8:00? None of the standard ways for outlook or personal folders will work on Exchange 2003 PF's.

Glen said...

I don't believe this is possible its kind of like free/busy there just no provision for this. Eg you cant enable a public calendar folder to do direct booking either.


barry said...

Hi do you know if its possible to get all calendars for all users using EWS api for user that has full control of all user's calendar?