Forum Discussion
Lead hours for scheduling a Teams Room/Meeting Room
There is a way to set the maximum amount of days in advance that a resource account for a Teams room or meeting room can be booked (Set-CalendarProcessing (ExchangePowerShell) | Microsoft Learn), but I'm not finding a way to specify a minimum amount of lead time for a resource account to be booked.
Is there something that I'm missing in the documentation or another way to implement a 24 hour lead time to book a resource account so that users cannot book meetings in the same day for rooms?
2 Replies
- LeonPavesicSilver Contributor
Hi TimLB,
While there may not be a specific built-in cmdlet for this, you can create a PowerShell script to periodically check and decline or remove meetings that are booked within the minimum lead time.
# Define the minimum lead time in hours $minimumLeadTimeHours = 24 # Get the current time $currentTime = Get-Date # Connect to Exchange Online (if you're using Exchange Online) # Connect-ExchangeOnline -UserPrincipalName email address removed for privacy reasons -ShowProgress $true # Get the resource calendar $resourceCalendar = Get-Mailbox -Identity "email address removed for privacy reasons" | Get-CalendarFolder -Identity calendar # Get all the meetings in the resource calendar $meetings = Get-CalendarItem -CalendarFolder $resourceCalendar -ResultSize Unlimited foreach ($meeting in $meetings) { $startTime = $meeting.Start $timeDifference = ($startTime - $currentTime).TotalHours # Check if the meeting is within the minimum lead time if ($timeDifference < $minimumLeadTimeHours) { # Decline or remove the meeting # Decline example: $meeting.Decline() # Remove example: $meeting | Remove-CalendarEvent } } # Disconnect from Exchange Online # Disconnect-ExchangeOnline -Confirm:$false
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic (LinkedIn)
- TimLBIron ContributorI think this would be useable logic, but with modification. Using the current date will end with some meetings being cancelled depending on when the script runs. So, if there is a field on the meeting that tracks the date that the meeting was created. (StartDateTime - CreatedDateTime)
This is helpful, but I don't think it would be the answer if there aren't any commands in the EXO PowerShell module that support retrieving the data. Going down the research path, the Graph API might have the solution. https://learn.microsoft.com/en-us/graph/outlook-get-shared-events-calendars