{"id":1366,"date":"2016-03-29T17:56:22","date_gmt":"2016-03-29T22:56:22","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=1366"},"modified":"2016-11-02T16:05:48","modified_gmt":"2016-11-02T21:05:48","slug":"freebusy-time-segmentation-in-exchange-online","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2016\/03\/freebusy-time-segmentation-in-exchange-online\/","title":{"rendered":"Free\/Busy Time Segmentation in Exchange Online"},"content":{"rendered":"<p>By default, all users in the same Exchange Online environment can view each other&#8217;s free\/busy time. Using the <em>Organization&#8211;Sharing<\/em> settings you can share more information, but not less.<\/p>\n<figure id=\"attachment_1428\" aria-describedby=\"caption-attachment-1428\" style=\"width: 452px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2016\/03\/freebusy-time-segmentation-in-exchange-online\/exchange_online_sharing_rule_cropped\/\" rel=\"attachment wp-att-1428\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/osric.com\/chris\/accidental-developer\/wp-content\/uploads\/2016\/03\/exchange_online_sharing_rule_cropped.png\" alt=\"Exchange Online Sharing Rule\" width=\"452\" height=\"601\" class=\"size-full wp-image-1428\" srcset=\"https:\/\/osric.com\/chris\/accidental-developer\/wp-content\/uploads\/2016\/03\/exchange_online_sharing_rule_cropped.png 452w, https:\/\/osric.com\/chris\/accidental-developer\/wp-content\/uploads\/2016\/03\/exchange_online_sharing_rule_cropped-226x300.png 226w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/a><figcaption id=\"caption-attachment-1428\" class=\"wp-caption-text\">Unchecking the &#8216;Share your calendar folder&#8217; box does not turn off calendar sharing. Counterintuitive!<\/figcaption><\/figure>\n<p>Individuals can adjust their own free\/busy time sharing in Outlook or Outlook Web App (OWA). But what if you have less-privileged users who should not be able to view another user&#8217;s free\/busy time, for example, temporary employees or contract workers? Can they be restricted from viewing calendar information for other users?<\/p>\n<p>It can be done, but it&#8217;s not simple.<\/p>\n<p><strong>My 3-part approach, summarized:<\/strong><\/p>\n<ol>\n<li>Change each user&#8217;s sharing settings for the Default user to None via PowerShell<\/li>\n<li>Create a mail-enabled universal security group containing all privileged users. (Fortunately, this group already existed within my organization.)<\/li>\n<li>Change each user&#8217;s sharing settings for the security group created above to AvailabilityOnly via PowerShell (to allow just Free\/Busy visibility)<\/li>\n<\/ol>\n<p>I found <a href=\"http:\/\/theitbros.com\/add-calendar-permissions-in-office-365-via-powershell\/\">Add Calendar Permissions in Office 365 via Powershell<\/a>, which was a tremendous help in discovering the format of the calendar folder. For example, to adjust the Default user&#8217;s access to chris@example.com&#8217;s calendar to None, use the following PowerShell command:<br \/>\n<code>Set-MailboxFolderPermission -Identity chris@example.com:\\calendar -user Default -AccessRights None<\/code><\/p>\n<p>Then I tried to add permissions for the security group:<br \/>\n<code>$mycal = 'chris@example.com:\\calendar'<br \/>\nSet-MailboxFolderPermission -Identity $mycal -User privileged-users-security-group@example.com -AccessRights AvailabilityOnly<\/code><\/p>\n<p><strong>Error:<\/strong><br \/>\n<code>There is no existing permission entry found for user: privileged-users-security-group.<br \/>\n    + CategoryInfo          : NotSpecified: (:) [Set-MailboxFolderPermission], UserNotFoundInPermissionEntryException<br \/>\n    + FullyQualifiedErrorId : [Server=BLUPR0101MB1603,RequestId=d057882d-5663-417d-a614-ce73e5ab0565,TimeStamp=3\/15\/20<br \/>\n   16 3:41:20 PM] [FailureCategory=Cmdlet-UserNotFoundInPermissionEntryException] B65CA2A0,Microsoft.Exchange.Managem<br \/>\n  ent.StoreTasks.SetMailboxFolderPermission<br \/>\n    + PSComputerName        : ps.outlook.com<\/code><\/p>\n<p>Thanks to <a href=\"https:\/\/arkkar.wordpress.com\/2013\/10\/20\/setup-secretary-permissions-to-manager-calendar-in-office-365\/\">Setup secretary permissions to manage Calendar in Office 365<\/a>, I discovered that the above error occurred because the security group had no current settings for the specified calendar. In that case, the <code>Add-MailboxFolderPermission<\/code> is the appropriate command:<\/p>\n<p><code>Add-MailboxFolderPermission -Identity $mycal -User privileged-users-security-group@example.com -AccessRights AvailabilityOnly<\/code><\/p>\n<p>Before running this across all of our users, I wanted to find out which users had customized their free\/busy sharing settings. If they had customized them, I wanted to preserve their settings. For example, I decided to get the Default user sharing settings for the sales department users&#8217; calendars:<\/p>\n<p><code>$DeptMailboxes = Get-Mailbox -Filter {CustomAttribute2 -eq 'sales'}<br \/>\nForEach ($Mailbox In $DeptMailboxes) { $Calendar = $Mailbox.UserPrincipalName + \":\\calendar\"; Get-MailboxFolderPermission -Identity $Calendar -User Default}<\/code><\/p>\n<p>Unfortunately, the above did not return all of the properties needed to identify the calendars in question:<br \/>\n<code>Calendar             Default              {AvailabilityOnly}<br \/>\nCalendar             Default              {LimitedDetails}<br \/>\nCalendar             Default              {AvailabilityOnly}<br \/>\nCalendar             Default              {AvailabilityOnly}<\/code><\/p>\n<p>I specified a list of properties that was more useful:<br \/>\n<code>ForEach ($Mailbox In $DeptMailboxes) { $Calendar = $Mailbox.UserPrincipalName + \":\\calendar\"; Get-MailboxFolderPermission -Identity $Calendar -User Default | Select Identity,FolderName,User,AccessRights }<\/code><\/p>\n<p>Fortunately, only a handful of the users in my organization had customized their sharing settings, so I simply noted their settings and re-applied them after running these settings across all users in the organization:<\/p>\n<p><code>$AllMailboxes = Get-Mailbox<br \/>\nForEach ($Mailbox In $AllMailboxes) { $Calendar = $Mailbox.UserPrincipalName + \":\\calendar\"; Set-MailboxFolderPermission -Identity $Calendar -User Default -AccessRights None; Add-MailboxFolderPermission -Identity $Calendar -User privileged-users-security-group@example.com -AccessRights AvailabilityOnly }<\/code><\/p>\n<p>This achieved the desired free\/busy time segmentation. However, there&#8217;s one snag: what happens when new users are added? They will have the default sharing settings. That means that every time a new user is added, these steps will need to be run for that new user. I created the following PowerShell script &#8212; I can pipe the results of <code>Get-Mailbox<\/code> to this script to apply the customizations described above:<\/p>\n<pre><code>param(  \r\n    [Parameter(\r\n        Position=0, \r\n        Mandatory=$true, \r\n        ValueFromPipeline=$true,\r\n        ValueFromPipelineByPropertyName=$true)\r\n    ]\r\n    [Object[]]$Mailbox\r\n)\r\n\r\nProcess {\r\n    $Calendar = $Mailbox.UserPrincipalName + \":\\calendar\"\r\n    Set-MailboxFolderPermission -Identity $Calendar -User Default -AccessRights None\r\n    Add-MailboxFolderPermission -Identity $Calendar -User 'privileged-users-security-group@example.com' -AccessRights AvailabilityOnly\r\n}<\/code><\/pre>\n<p>To run the script (assuming it is named Set-CustomFreeBusySharing.ps1):<br \/>\n<code>Get-Mailbox -Identity bob@example.com | .\/Set-CustomFreeBusySharing.ps1<\/code><\/p>\n<p>Fully integrating that into my account creation process is a job for another day.<\/p>\n<p>One other thing to note: users can still choose to modify their free\/busy sharing with the Default user, in case they do want\/need to share their availability with all users in the organization.<\/p>\n<p>Other sites that had useful information while I researched this issue:<\/p>\n<ul>\n<li>Sharing policies: <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/jj916676%28v=exchg.150%29.aspx\">Create a sharing policy in Exchange Online<\/a><\/li>\n<li>How to set sharing to None for the Default user: <a href=\"https:\/\/community.office365.com\/en-us\/f\/158\/p\/433797\/1100939?ss=89168bed-97b1-4925-b8a2-984dd710c29e#1100939\">Calendar default shared with People in my organisation<\/a><\/li>\n<li>Setting free\/busy permissions via PowerShell: <a href=\"https:\/\/support.microsoft.com\/en-us\/kb\/2865291\">How to set Free\/Busy permissions in Exchange Management Shell in Office 365 dedicated<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>It is not possible to segment free\/busy time sharing in Exchange Online using only organization sharing rules. I describe one way to achieve free\/busy time segmentation in Exchange Online using PowerShell to set default sharing to None for each user, and then enable sharing of availability information with a specific segment of users.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[393],"tags":[395,397,396,374,394,376,228],"class_list":["post-1366","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-calendar","tag-calendar-permissions","tag-calendar-sharing","tag-exchange-online","tag-freebusy","tag-o365","tag-powershell"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=1366"}],"version-history":[{"count":18,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1366\/revisions"}],"predecessor-version":[{"id":1610,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1366\/revisions\/1610"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=1366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=1366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=1366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}