Get Mailbox Out of Office Configuration PowerShell
Hello,
In some previous posts we saw how to configure Out of Office for another user or for a shared mailbox. As of today, we’re in a intensive holiday period, you may want to get a list of every person which enables their OoF in your Exchange infrastructure. You can do this with PowerShell, as usual:
Get-Mailbox | Get-MailboxAutoReplyConfiguration | ? {$_.AutoReplyState -eq 'Enabled' -or $_.'AutoReplyState' -eq 'Scheduled'} | select Identity,AutoReplyState,EndTime
This will get all mailboxes in your scope and then get the OoF configuration, and then it will filter out the people who didn’t activate or schedule it:
As you can see, the “EndTime” is not accurate when the “AutoreplyState” is “Enabled”, it’s normal because this mode of activation is “On/Off”, so there’s no date associated with it. We can make a more friendly output like:
Note: You may want to use the “-ResultSize” parameter to rise the number of mailbox returned.
Get-Mailbox | Get-MailboxAutoReplyConfiguration | ? {$_.AutoReplyState -eq 'Enabled' -or $_.'AutoReplyState' -eq 'Scheduled'} | select Identity,AutoReplyState,@{Label='EndDate';Expression={if($_.AutoReplyState -eq 'Scheduled'){$_.EndTime}else{'N/A'}}}
With this line, you won’t be disturb with the “EndTime” back in time from today. You can add a pipe to export to a CSV or to “Out-GridView” for a better visualization of the output:
Get-Mailbox | Get-MailboxAutoReplyConfiguration | ? {$_.AutoReplyState -eq 'Enabled' -or $_.'AutoReplyState' -eq 'Scheduled'} | select Identity,AutoReplyState,@{Label='EndDate';Expression={if($_.AutoReplyState -eq 'Scheduled'){$_.EndTime}else{'N/A'}}} | Out-GridView -Title 'Out of Office'
This window is a nice table view that you can filter and search just like an Excel spreadsheet.