Skip to content

Set-ResourceProperties

Exchange Online: Sets resource mailbox properties

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$MailboxId,
    [switch]$AccountDisabled,
    [string]$Alias,
    [string]$DisplayName,
    [int]$ResourceCapacity,
    [string]$WindowsEmailAddress,
    [bool]$AllBookInPolicy,
    [bool]$AllowRecurringMeetings,
    [int]$BookingWindowInDays,
    [bool]$EnforceSchedulingHorizon,
    [int]$MaximumDurationInMinutes,
    [bool]$ScheduleOnlyDuringWorkHours
)

Process {
    try {
        [string[]]$Properties = @('AccountDisabled','Alias','DisplayName','ResourceCapacity','WindowsEmailAddress')
        [string[]]$calProperties = @('AllBookInPolicy','AllowRecurringMeetings','BookingWindowInDays','EnforceSchedulingHorizon','MaximumDurationInMinutes','ScheduleOnlyDuringWorkHours')

        $box = Get-Mailbox -Identity $MailboxId -ErrorAction Stop
        if ($null -eq $box) {
            throw "Resource $($MailboxId) not found"
        }

        if (-not [System.String]::IsNullOrWhiteSpace($Alias)) {
            $null = Set-Mailbox -Identity $MailboxId -Alias $Alias -ErrorAction Stop
        }
        if (-not [System.String]::IsNullOrWhiteSpace($DisplayName)) {
            $null = Set-Mailbox -Identity $MailboxId -DisplayName $DisplayName -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('ResourceCapacity')) {
            $null = Set-Mailbox -Identity $MailboxId -ResourceCapacity $ResourceCapacity -ErrorAction Stop
        }
        if (-not [System.String]::IsNullOrWhiteSpace($WindowsEmailAddress)) {
            $null = Set-Mailbox -Identity $MailboxId -WindowsEmailAddress $WindowsEmailAddress -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('AllBookInPolicy')) {
            $null = Set-CalendarProcessing -Identity $MailboxId -AllBookInPolicy $AllBookInPolicy -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('AllowRecurringMeetings')) {
            $null = Set-CalendarProcessing -Identity $MailboxId -AllowRecurringMeetings $AllowRecurringMeetings -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('BookingWindowInDays')) {
            $null = Set-CalendarProcessing -Identity $MailboxId -BookingWindowInDays $BookingWindowInDays -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('EnforceSchedulingHorizon')) {
            $null = Set-CalendarProcessing -Identity $MailboxId -EnforceSchedulingHorizon $EnforceSchedulingHorizon -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('MaximumDurationInMinutes')) {
            $null = Set-CalendarProcessing -Identity $MailboxId -MaximumDurationInMinutes $MaximumDurationInMinutes -ErrorAction Stop
        }
        if ($PSBoundParameters.ContainsKey('ScheduleOnlyDuringWorkHours')) {
            $null = Set-CalendarProcessing -Identity $MailboxId -ScheduleOnlyDuringWorkHours $ScheduleOnlyDuringWorkHours -ErrorAction Stop
        }
        if (-not $PSBoundParameters.ContainsKey('AccountDisabled')) {
            $AccountDisabled = $box.AccountDisabled
        }
        $null = Set-Mailbox -Identity $box.Name -AccountDisabled:$AccountDisabled -Confirm:$false -ErrorAction Stop

        $ts = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        $result = Get-Mailbox -Identity $MailboxId -ErrorAction Stop | Select-Object $Properties
        $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue $ts -PassThru -Force
        Write-Output $result

        $calResult = Get-CalendarProcessing -Identity $MailboxId -ErrorAction Stop | Select-Object $calProperties
        $calResult | Add-Member -NotePropertyName Timestamp -NotePropertyValue $ts -PassThru -Force
        Write-Output $calResult
    }
    catch { throw }
}

Alias, Display name, Distinguished name, SamAccountName, Guid or user principal name of the resource

Off

Disable the account associated with the resource

Alias name of the resource

Display name of the resource

Capacity of the resource

Windows email address of the resource

Automatically approve in-policy requests from all users

Allow recurring meetings

Maximum number of days in advance that the resource can be reserved

Behavior of recurring meetings that extend beyond the BookingWindowInDays

Duration in minutes for meeting requests

Allow meetings to be scheduled outside of working hours

An interactive directory of PowerShell scripts.