Get-OOHMessage.ps1


Description

Purpose

Retrieves the current Out of Office (OOH) settings for a mailbox in Exchange Online.

Detailed Description

This function queries Exchange Online for the specified mailbox and returns the auto-reply state, internal and external messages, and scheduling details.

Back to Top

Usage

Example 1

Get-OOHMessage -Identity "[email protected]"

Back to Top

Notes

No additional notes.

Back to Top


Script

function Get-OOHMessage {
    <#
    .SYNOPSIS
        Retrieves the current Out of Office (OOH) settings for a mailbox in Exchange Online.

    .DESCRIPTION
        This function queries Exchange Online for the specified mailbox and returns the auto-reply state, internal and external messages, and scheduling details.

    .PARAMETER Identity
        The identity (email address or alias) of the mailbox to check.

    .EXAMPLE
        Get-OOHMessage -Identity "[email protected]"
    #>
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]$Identity
    )

    try {
        $config = Get-MailboxAutoReplyConfiguration -Identity $Identity
        [PSCustomObject]@{
            Identity         = $config.Identity
            AutoReplyState   = $config.AutoReplyState
            InternalMessage  = $config.InternalMessage
            ExternalMessage  = $config.ExternalMessage
            StartTime        = $config.StartTime
            EndTime          = $config.EndTime
            Enabled          = $config.AutoReplyState -ne 'Disabled'
        }
    }
    catch {
        Write-Error \"Failed to retrieve OOH settings for ${$Identity}: $_\"
    }
}

Back to Top

Download

Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.

Issue


Back to Top