Exchange Calendar properties report

Modified on Fri, 16 May at 11:54 AM

This script will export a report of the properties of all Room Calendar mailboxes


# Check if ExchangeOnlineManagement module is available
if (-not (Get-Module -ListAvailable -Name ExchangeOnlineManagement)) {
    Write-Host "ExchangeOnlineManagement module not found. Installing..." -ForegroundColor Yellow
    Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -Force
}

# Import the module
Import-Module ExchangeOnlineManagement -Force

# Connect to Exchange Online
try {
    Connect-ExchangeOnline -ErrorAction Stop
} catch {
    Write-Host "Failed to connect to Exchange Online. Please ensure you have the right permissions and network access." -ForegroundColor Red
    exit
}

# Get all room mailboxes
$rooms = Get-Mailbox -RecipientTypeDetails RoomMailbox

# Display numbered list of rooms
Write-Host "Select a room to export (enter the number):"
Write-Host "0. Export all rooms"
for ($i = 0; $i -lt $rooms.Count; $i++) {
    Write-Host "$($i + 1). $($rooms[$i].DisplayName)"
}

# Read user selection
[int]$selection = Read-Host "Enter your choice"

# Validate input
if ($selection -lt 0 -or $selection -gt $rooms.Count) {
    Write-Host "Invalid selection. Exiting."
    exit
}

# Prepare export directory
$exportDir = "C:\SmartSpace"
if (-not (Test-Path -Path $exportDir)) {
    New-Item -ItemType Directory -Path $exportDir -Force | Out-Null
}

# Function to gather and format mailbox + calendarprocessing info
function Get-MailboxWithCalendarProcessing($room) {
    $calendarSettings = Get-CalendarProcessing -Identity $room.Identity
    $combined = @{}

    foreach ($property in $room.PSObject.Properties) {
        if ($property.Name -notin @("PSComputerName", "RunspaceId", "PSShowComputerName")) {
            $combined["Mailbox_$($property.Name)"] = $property.Value
        }
    }

    foreach ($property in $calendarSettings.PSObject.Properties) {
        if ($property.Name -notin @("PSComputerName", "RunspaceId", "PSShowComputerName")) {
            $combined["CalProc_$($property.Name)"] = $property.Value
        }
    }

    return New-Object PSObject -Property $combined
}

# Get selected room(s)
if ($selection -eq 0) {
    $results = $rooms | ForEach-Object { Get-MailboxWithCalendarProcessing $_ }
    $exportPath = Join-Path -Path $exportDir -ChildPath "AllRooms_Report.csv"
} else {
    $room = $rooms[$selection - 1]
    $results = @(Get-MailboxWithCalendarProcessing $room)
    $exportPath = Join-Path -Path $exportDir -ChildPath "$($room.Alias)_Report.csv"
}

# Export results
$results | Export-Csv -Path $exportPath -NoTypeInformation -Encoding UTF8
Write-Host "Export complete: $exportPath"

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article