SHELL/1.3.9.ps1

$CheckId = "1.3.9"
$Title = "Ensure shared Bookings pages are restricted to select users"

try {
    $OwaPolicy = Get-OwaMailboxPolicy -Identity OwaMailboxPolicy-Default | Select-Object Identity,BookingsMailboxCreationEnabled
    $OrgConfig = Get-OrganizationConfig | Select-Object BookingsEnabled

    $Pass = ($OrgConfig.BookingsEnabled -and -not $OwaPolicy.BookingsMailboxCreationEnabled)

    [pscustomobject]@{
        CheckId   = $CheckId
        Title     = $Title
        Status    = if ($Pass) { "PASS" } else { "FAIL" }
        Pass      = $Pass
        Evidence  = [pscustomobject]@{
            OrganizationConfig = $OrgConfig
            OwaMailboxPolicy   = $OwaPolicy
        }
        Error     = $null
        Timestamp = Get-Date
    }
}
catch {
    [pscustomobject]@{
        CheckId   = $CheckId
        Title     = $Title
        Status    = "ERROR"
        Pass      = $null
        Evidence  = $null
        Error     = $_.Exception.Message
        Timestamp = Get-Date
    }
}