PowerShell script to find meeting requests in Exchange mailbox and accept them
Is it possible to create a PowerShell script that will go into a mailbox (specifically for a meeting room), find all it's meeting requests and accept them?
We've implemented a new mechanism in our exchange environment so that requests sent to meeting rooms will be auto-accepted if the room is available, but there are a lot of old requests (especially recurring meetings) that were sent before this change that are marked as tentative. This is a problem because when a new request is sent for a time that is marked as tentative, it will accept the request, which is leading to some conflicts.
Solution 1:
I'm a little late to the party; I imagine you're probably past this issue by now, but I just read this question today and thought it would be a fun exercise so here is the answer to your question. This bit of Powershell will log in to a Mailbox using the Outlook client, go through the Inbox and automatically accept any meeting invites. You can obviously tweak the code to be more to your liking (such as logging in to a different mailbox) but this would definitely get you started if you were still interested:
[Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.Outlook") | Out-Null
$Folders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -As [Type]
$Outlook = New-Object -ComObject Outlook.Application
$Namespace = $Outlook.GetNameSpace("MAPI")
$Inbox = $Namespace.getDefaultFolder($Folders::olFolderInbox)
ForEach ($_ In $Inbox.Items)
{
If ($_.MessageClass -eq "IPM.Schedule.Meeting.Request")
{
$AppointmentItem = $_.GetAssociatedAppointment($true)
$Response = $AppointmentItem.Respond(3,$True,$False)
$Response.Send()
}
}