Seamlessly scheduling meetings and collaborating effectively is paramount in today’s fast-paced work environment. Over the years, I’ve seen firsthand the transformative impact of automating calendar-sharing settings on organizational efficiency. This experience has reinforced my belief in transparency and ease of meeting booking as critical components for fostering effective collaboration within organizations. Join me as I delve into the automatic calendar availability routine of 2024.
Table Of Contents
The History Of Automatic Calendar Availability
As part of Microsoft 365, Microsoft Exchange has a feature for sharing calendar presence between users within an organization. This enables users to share their availability with varying levels of detail, from simple free/busy information to detailed meeting subjects and locations. While access control is typically left to the end user, organizations can greatly benefit from taking control of this feature to ensure openness and transparency.
Historically, automating these settings involved leveraging PowerShell scripts running as scheduled tasks within on-premises Exchange environments or targeting Exchange Online using the ExchangeOnlineManagement PowerShell module from a land-based server.
Here is an example script from one of my old routines. One of the challenges here was handling the calendar naming across language variations.
<#
This script sets default calendar permissions for all users in an Office 365 environment to a given value.
Reviewer: FolderVisible, ReadItems
AvailabilityOnly: View only availability data
LimitedDetails: View availability data with subject and location
2017.10.30 - Simon Skotheimsvik
https://docs.microsoft.com/en-us/powershell/module/exchange/set-mailboxfolderpermission?view=exchange-ps
Find format: (Get-MailboxFolderStatistics <username> -FolderScope Calendar).Identity
#>
# Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
# Generate a list of all mailboxes
$users = Get-Mailbox -ResultSize Unlimited
# Set default access to Reviewer for all mailboxes
foreach ($user in $users) {
Write-Host -ForegroundColor Green "User in focus: $($user.UserPrincipalName)"
# Set variable for English Calendar
$IdentityCal = "$($user.Alias):\Calendar"
$error.Clear()
Get-MailboxFolderPermission -Identity $IdentityCal -ErrorAction SilentlyContinue
if ($error[0]) {
Write-Host -ForegroundColor Cyan "Can't find Calendar - checking Kalender"
# Set variable for Norwegian Calendar
$IdentityCal = "$($user.Alias):\Kalender"
}
Write-Host -ForegroundColor Green "Setting permission for $IdentityCal"
Set-MailboxFolderPermission -Identity $IdentityCal -User Default -AccessRights LimitedDetails
}
PowerShellThese scripts ensured calendar sharing settings were consistently applied across the organization, reducing the administrative burden and minimizing human error.
The Future Of Automatic Calendar Availability
With the transition to cloud-based solutions, the old PowerShell module didn´t comply with current cloud technologies. My colleague Alexander Holmeset and I have modernized these routines to leverage Exchange Online using Microsoft Graph running on a schedule in Azure Automation with a managed identity. We are utilizing the Microsoft.Graph.Calendar module.
Alexander has created a detailed blog post on how we set up the routine in Azure Automation. Take a look at his blog for these details: Set Default Calendar Permission for your Organization with Graph API! | A blog about automation and technologies in the cloud (alexholmeset.blog)
My Variations
After working more on the solution, it has become somewhat more refined. Therefore, I am sharing it the way “Simon does”. First, here is my small script that assigns permissions to the managed identity.
<#
.SYNOPSIS
Created on: 19.02.2024
Created by: CloudWay, Simon Skotheimsvik
Info: Entra Role Assignments
.DESCRIPTION
Routine to add necessary roles to System Assigned Managed Identity in Function App or Automation Account.
#>
# Install-Module Microsoft.Graph -Scope CurrentUser
Import-Module Microsoft.Graph.Applications
# Variables
$TenantID = "YOUR VALUE HERE"
$managedIdentityId = "YOUR VALUE HERE"
$roleNames = "User.Read.All","Calendars.ReadWrite"
# Connect to Graph
Connect-MgGraph -Scopes Application.Read.All, AppRoleAssignment.ReadWrite.All, RoleManagement.ReadWrite.Directory -TenantId $TenantID
# Get the Microsoft Graph Service Principal
$msgraph = Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'"
# Set the app role assignments
foreach ($roleName in $roleNames) {
write-host $roleName
$role = $Msgraph.AppRoles| Where-Object {$_.Value -eq $roleName}
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $managedIdentityId -PrincipalId $managedIdentityId -ResourceId $msgraph.Id -AppRoleId $role.Id
}
Disconnect-MgGraph
PowerShellNext is the modern version of the original script shared at the top of this post. This is the script Alexander helped update. This is my interpretation of the script.
<#
.SYNOPSIS
Name: RUNBOOK-SetExchangeCalendarPermissions.ps1
Author: Alexander Holmeset, https://alexholmeset.blog, https://x.com/AlexHolmeset
Contributor: Simon Skotheimsvik, http://skotheimsvik.no, https://x.com/SSkotheimsvik
Instructions: https://alexholmeset.blog/2024/06/11/set-default-calendar-permission-for-your-organization-with-graph-api/
Versions: 1.0 - 2017.10.30 - Simon Skotheimsvik, initial version using ExchangeOnline module
1.1 - 2024.06.12 - Alexander Holmeset, updated to use Microsoft Graph PowerShell SDK
1.2 - 2024.06.13 - Simon Skotheimsvik, tuned the script more towards Azure Automation.
.DESCRIPTION
This script sets the default calendar permissions for all users in a Microsoft 365 organization to LimitedRead.
#>
# Set the permission level to be set on the calendars.
# Options can be found here: https://learn.microsoft.com/en-us/graph/api/resources/calendarpermission?view=graph-rest-1.0#calendarroletype-values
$Permission = "LimitedRead"
# Connects to Microsoft Graph with the specified scopes
Connect-MgGraph -Identity
# Generates a list of all licensed users in the Microsoft 365 organization with a mailbox
$users = Get-MgUser -All -Property "id", "AssignedLicenses", "UserPrincipalName", "Mail" | Where-Object { $_.AssignedLicenses.Count -gt 0 -and $_.Mail -ne $null}
#$users = Get-MgUser -All -Property "id", "AssignedLicenses", "UserPrincipalName", "Mail" | Where-Object { $_.AssignedLicenses.Count -gt 0 -and $_.Mail -ne $null -and $_.UserPrincipalName -eq "simon.skotheimsvik@domain.com"}
# Sets default access to LimitedRead for all calendars in each user's mailbox
foreach ($user in $users) {
# Prints the user currently in focus
Write-Output "User in focus = $($user.userprincipalname)"
# Initializes the variables to store calendar permissions
$CalenderPermissions = @()
$CalenderPermissions = Get-MgUserCalendarPermission -UserId $user.id
# If the user has any calendar permissions, update them
if ($CalenderPermissions) {
$CalenderPermissionsMyOrg = @()
$CalenderPermissionsMyOrg = $CalenderPermissions | Where-Object { $_.EmailAddress.Name -eq "My Organization" }
# Updates the calendar permissions for the user
if ($CalenderPermissionsMyOrg.Role -ne $Permission) {
Write-Warning "- Changing MyOrg-permission on calendar for $($user.userprincipalname) from $($CalenderPermissionsMyOrg.Role) to $($Permission)."
Update-MgUserCalendarPermission -UserId $user.id -Role $Permission -CalendarPermissionId $CalenderPermissionsMyOrg.id
}
# If the permission is already set, print a message
else {
Write-Output "- MyOrg-permission already set to $($Permission) on calendar for $($user.userprincipalname)."
}
}
}
PowerShellThis script running on a schedule allows for sophisticated and reliable automation, providing a robust solution that meets the demands of modern cloud-based infrastructures.
The script provides detailed logs of each run.
Above is a glimpse from “All Logs”. Below, you see how the warnings are available in the Warnings tab.
These logs can be useful for tracking any changes made. If interested, you can also build the solution more and send logs to Microsoft Teams channels for each permission change.
Automation Is Key
Despite these technological advancements, the core challenge remains unchanged: organizations need transparency in calendar presence. Manual routines, prone to human mistakes and user overrides, are not viable in large organizations. Automation is key to ensuring a consistent experience and uniform settings for all users, whether they are new hires or long-standing employees.
Streamlined Efficiency
Automating calendar availability settings enhances transparency and streamlines the meeting booking process. Having a clear view of colleagues’ availability allows employees to schedule meetings more efficiently, reducing the time spent coordinating schedules and minimizing the frustration of back-and-forth communications.
This improved efficiency can positively impact overall productivity and job satisfaction.
Copilot And Third-Party Benefits
Moreover, consistent calendar availability settings can enhance the effectiveness of tools like Microsoft Copilot, which relies on accurate and up-to-date calendar data to provide intelligent assistance. Users can benefit from more accurate scheduling suggestions and other AI-driven features by ensuring that calendar settings are uniformly applied across the organization.
Consultancy businesses can also utilize up-to-date calendars in online booking solutions like Microsoft Bookings. Calendar integrations are also popular in switchboard applications, giving operators up-to-date knowledge of workforce presence.
Respect Privacy
Of course, privacy remains a crucial consideration. While transparency is important, it is equally essential to respect individual privacy. Appointments not intended for organizational visibility must be marked as private by the end user.
This ensures that sensitive information, such as HR details or personal medical appointments, remains confidential while providing the necessary transparency for effective scheduling.
Concluding Automatic Calendar Availability
In conclusion, automating calendar availability is critical to boosting productivity and fostering a collaborative work environment. By leveraging modern tools like Microsoft Graph, organizations can ensure a consistent and efficient approach to calendar management, benefiting employees and the organization. As we move further into the cloud era, the importance of automation in maintaining transparency and efficiency cannot be overstated.
Be First to Comment