Skip to main content

Showing which mailboxes have been enabled with Outlook Direct Booking via a script

Outlook direct booking is one of the many ways in which you can handle resource mailboxes in Exchange for a full list of other methods have a look at slipstick. Knowing which mailboxes have been enabled in your Exchange Organization could be a little tricky to keep a track of if you have a large number of mailboxes. One method of finding what mailboxes are using Direct booking is by using the freebusy data on a server. How Free-Busy data works and is stored is documented on Technet and this post on the Exchange Team Blog . The Free Busy data also comes into to play with Outlook Direct booking. When a user configures direct booking via the 3 check boxes under resource scheduling in Outlook – Calendar options there are 3 Mapi properties that get set on the local freebusy object in a mailbox. (Note this is not the only thing that happens you do enable direct booking permissions are also modified on the calendar and freebusy object in the resource mailbox)

Automatically accept meeting and process cancellations relates to 0x686D000B
Automatically decline conflicting meeting requests relates to 0x686F000B
Automatically decline recurring meeting requests relates to 0x686E000B

These properties are also published on the users freebusy object located in the SCHEDULE+ FREE BUSY public folder. When a user creates an appointment and selects a mailbox as a resource Outlook queries the public free busy object for that mailbox to determine if Direct Booking is enabled. So basically what you can do in a script is to walk the objects in the public free busy folder and check for these properties on each of the objects. If you read the documentation in the links I provided above you will see that Freebusy data is stored per Administrative Group in Exchange. The script I wrote uses CDO 1.2 to connect to a mailbox (its not really that important which mailbox as long as it is publishing freebusy data). In then uses the PR_FREEBUSY_ENTRYIDS 0x36E41102 mapi property which is a multivalued binary property stored in the root of a mailbox that holds the EntryID’s of various freebusy objects for that mailbox. The second ID in the prop holds the EntryID for the local freebusy object the third holds the EntryID for the public freebusy object for this mailbox. I’ve made use of this third one by using it to connect to the public freebusy object of the mailbox the script is connecting to and then just moving up to the parent folder object which will give the script the ability to walk all the objects in the public freebusy folder by using the message collection of this parent folder. To finish with the script generates a small html report called DOBreport.htm is c:\temp with a list of what mailboxes have direct booking enabled and what resource scheduling options have been selected. If you have multiple Administrative groups in your Exchange Organization you will need to connect to a mailbox in each exchange admin group to cover all mailboxes. Before running the script you need to configure the following two variables with the servername and mailbox of a mailbox to use.

MailServer = "servername"
Mailbox = "mailbox"

I’ve put a downloadable copy of the script here the script itself look like

MailServer = "mailbox"
Mailbox = "user"
Const PR_FREEBUSY_ENTRYIDS = &H36E41102
Const PR_PARENT_ENTRYID = &H0E090102
Const PR_RECALCULATE_FREEBUSY = &H10F2000B
Const PR_FREEBUSY_DATA = &H686C0102
report = "<table border=""1"" width=""100%"">" & vbcrlf
report = report & " <tr>" & vbcrlf
report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Mailbox-Name</font></b></td>"
& vbcrlf
report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Auto
Process Meetings</font></b></td>" & vbcrlf
report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Auto
Decline conflicts</font></b></td>" & vbcrlf
report = report & "<td align=""center"" bgcolor=""#000080""><b><font color=""#FFFFFF"">Auto
Decline recurring</font></b></td>" & vbcrlf
report = report & "</tr>" & vbcrlf

set objSession = CreateObject("MAPI.Session")
strProfile = MailServer & vbLf & Mailbox
objSession.Logon "",,, False,, True, strProfile
Set objInfoStores = objSession.InfoStores
set objInfoStore = objSession.GetInfoStore
Set objpubstore = objSession.InfoStores("Public Folders")
Set objRoot = objInfoStore.RootFolder

set non_ipm_rootfolder =
objSession.getfolder(objroot.fields.item(PR_PARENT_ENTRYID),objInfoStore.id)
fbids = non_ipm_rootfolder.fields.item(PR_FREEBUSY_ENTRYIDS).value
set publicfbusy = objSession.getmessage(fbids(2),objpubstore.id)
set publicfbusyfold =
objSession.getfolder(publicfbusy.fields.item(PR_PARENT_ENTRYID),objpubstore.id)
on error resume next
for each fbmess in publicfbusyfold.messages
wscript.echo fbmess.subject
wscript.echo "Automatically accept meeting and process cancellations : " &
fbmess.fields.item(&H686D000B)
wscript.echo "Automatically decline conflicting meeting requests : " &
fbmess.fields.item(&H686F000B)
wscript.echo "Automatically decline recurring meeting requests : " &
fbmess.fields.item(&H686E000B)
wscript.echo
if err.number <> 0 then
err.clear
else
if fbmess.fields.item(&H686D000B).value = true then
report = report & "<tr>" & vbcrlf
report = report & "<td align=""center"">" & fbmess.subject & "&nbsp;</td>" &
vbcrlf
report = report & "<td align=""center"">" & fbmess.fields.item(&H686D000B) &
"&nbsp;</td>" & vbcrlf
report = report & "<td align=""center"">" & fbmess.fields.item(&H686F000B) &
"&nbsp;</td>" & vbcrlf
report = report & "<td align=""center"">" & fbmess.fields.item(&H686E000B) &
"&nbsp;</td>" & vbcrlf
report = report & "</tr>" & vbcrlf
end if
end if
next
report = report & "</table>" & vbcrlf
Set fso = CreateObject("Scripting.FileSystemObject")
set wfile = fso.opentextfile("c:\temp\DOBreport.htm",2,true)
wfile.write report
wfile.close
set wfile = nothing
set fso = nothing

Popular posts from this blog

Export calendar Items to a CSV file using EWS and Powershell

Somebody asked about this last week and while I have a lot of EWS scripts that do access the Calendar I didn't have a simple example that just exported a list of the Calendar events with relevant information to a CSV file so here it is. I've talked on this one before in this howto  but when you query the calendar folder using EWS you need to use a CalendarView which will expand any recurring appointments in a calendar. There are some limits when you use a calendarview in that you can only return a maximum of 2 years of appointments at a time and paging will limit the max number of items to 1000 per call. So if you have a calendar with a very large number of appointments you need to break your query into small date time blocks. In this example script I'm just grabbing the next 7 days of appointments if you want to query a longer period you need to adjust the following lines (keeping in mind what I just mentioned) #Define Date to Query $StartDate = (Get-Date) $EndDate

Downloading a shared file from Onedrive for business using Powershell

I thought I'd quickly share this script I came up with to download a file that was shared using One Drive for Business (which is SharePoint under the covers) with Powershell. The following script takes a OneDrive for business URL which would look like https://mydom-my.sharepoint.com/personal/gscales_domain_com/Documents/Email%20attachments/filename.txt This script is pretty simple it uses the SharePoint CSOM (Client side object Model) which it loads in the first line. It uses the URI object to separate the host and relative URL which the CSOM requires and also the SharePointOnlineCredentials object to handle the Office365 SharePoint online authentication. The following script is a function that take the OneDrive URL, Credentials for Office365 and path you want to download the file to and downloads the file. eg to run the script you would use something like ./spdownload.ps1 ' https://mydom-my.sharepoint.com/personal/gscales_domain_com/Documents/Email%20attachments/filena

Writing a simple scripted process to download attachmentts in Exchange 2007/ 2010 using the EWS Managed API

Every complicated thing in life is made up of smaller simpler building blocks, when it comes to writing a script (or any code really) the more of these little building blocks you have to figure out the more the process of solving a problem can become bewildering. The Internet generally provides you with lots of half eaten sandwiches of information something someone else has taken a bite out but a lot of the time half done, and as with any code its usefulness declines over time as new and better API's and methods are derived. In this post I'm going to go through a simple scripted process that hopefully covers a few more of these smaller building blocks that you might face when asked to come up with a simple costless solution to perform an automated business function with a script. So the process im going to look at is one that comes up a lot and that is you have an Email that comes into to certain mailbox every day with a certain subject in my case "Daily Export" this
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.