How to free up the conference room calendar from terminated employees’ meetings? Here are the base line PowerShell commands for you to write a script.
To check if any meetings booked by employees in any of the conference rooms who no longer works in your office:
Get-Mailbox -RecipientTypeDetails RoomMailbox | Search-Mailbox -Searchquery "kind:meetings from:<DisplayName>" -EstimateResultOnly | Select Identity,ResultItemsCount | ft -AutoSize
Note: Replace <DisplayName> in the command above with terminated user’s display name.
To Delete the meetings booked by the terminated employees:
Get-Mailbox -RecipientTypeDetails RoomMailbox | Search-Mailbox -Searchquery "kind:meetings from:<DisplayName>" -DeleteContent -Force
Now the script to purge all meeting booked by terminated users.
Note: Change the SEARCHBASE options according to your AD environment. If you remove -SEARCHBASE option from Search-ADAccount command in the script, it will list all disabled accounts from entire domain.
<# * * * * * Purge Meetings Booked by Terminated Users * * * * * Delete meetings from conference rooms booked by employees terminated last 7 days. Written by: Anand, the Awesome Created on: 12/21/2018 #> $dt = date_time $logfile = ".\PurgeMeetings-of-termed-users" + $dt + ".log" Start-Transcript -Path $logfile #Get the terminiated user list <# Note: Important REPLACE THE SEARCH BASE - BASED ON YOUR AD ENVIRONMENT HERE BELOW #> $TermedUsers = Search-ADAccount -AccountDisabled -SearchBase 'OU=Users,DC=corp,DC=company,DC=com' #List all conference rooms $ConferenceRooms = Get-Mailbox -RecipientTypeDetails RoomMailbox foreach($TermedUser in $TermedUsers) { Write-Host "Processing $($Termeduser.Name).." #Delete tehe meeting booked by terminated user $ConferenceRooms | Search-Mailbox -Searchquery "kind:meetings from:$($TermedUser.Name)" -DeleteContent -Confirm:$false -Force } Stop-Transcript # * * * End of the Script * * *
I am looking for this script to run in schedule to delete the meetings of terminated users
I will post the script in this blog very soon.
Hello Anand……I just tried the force delete and all it did was display each room separately and show how many appts the user had in each room and did not show anything in regards to items removed. I also still see the users recurring meeting on one of the rooms I was spot checking. Does this not delete recurring meetings? The user is in AD still but disabled. Thanks, John
Hello John,
Search-Mailbox with “-DeleteContent” should delete all meetings including recurring. I think what you see is meetings were deleted and moved to “Deleted Items” folders. If you run the same command again, it will purge it from Deleted items.
Anand