Files
PowerShell-scripts/Exchange/Check-HybridOAuth-ExchangeOnline.ps1

54 lines
2.8 KiB
PowerShell

# ============================================================
# Hybrid OAuth Validatie Script - Exchange Online
# Draaien vanuit Exchange Online PowerShell (Connect-ExchangeOnline)
# ============================================================
# ============================================================
# CONFIGURATIE - Pas onderstaande variabelen aan per klant
# ============================================================
# Exchange Online mailbox om mee te testen (moet een cloud mailbox zijn)
$onlineMailbox = "clouduser@contoso.com"
# On-prem mailboxen om per stuk te testen (cloud -> on-prem richting)
# NB: Test-OAuthConnectivity in ExO vereist een ONLINE mailbox als -Mailbox parameter.
# Deze lijst wordt gebruikt voor de mailbox folder check, niet voor OAuth test.
$onpremMailboxes = @(
"onpremuser1@contoso.com",
"onpremuser2@contoso.com"
)
# On-premises EWS URL (externe URL)
$onPremEwsUrl = "https://mail.contoso.com/ews/exchange.asmx"
# ============================================================
# EINDE CONFIGURATIE
# ============================================================
Write-Host "`n============================================" -ForegroundColor Cyan
Write-Host " 1. OAuth Test: Exchange Online -> On-Prem" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
$ewsResult = Test-OAuthConnectivity -Service EWS `
-TargetUri $onPremEwsUrl `
-Mailbox $onlineMailbox
Write-Host "EWS ($onlineMailbox -> on-prem): $($ewsResult.ResultType)" -ForegroundColor $(if($ewsResult.ResultType -eq "Success"){"Green"}else{"Red"})
if ($ewsResult.ResultType -ne "Success") {
Write-Host "Detail: $($ewsResult.Detail)" -ForegroundColor Yellow
}
Write-Host "`n============================================" -ForegroundColor Cyan
Write-Host " 2. OrganizationRelationship (cloud)" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Get-OrganizationRelationship | Format-List Name, Enabled, FreeBusyAccessEnabled, FreeBusyAccessLevel, DomainNames, TargetAutodiscoverEpr
Write-Host "`n============================================" -ForegroundColor Cyan
Write-Host " 3. IntraOrganizationConnector (cloud)" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Get-IntraOrganizationConnector | Format-List Name, Enabled, TargetAddressDomains, DiscoveryEndpoint
Write-Host "`n============================================" -ForegroundColor Cyan
Write-Host " SAMENVATTING" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host "OAuth EWS (cloud -> on-prem): $($ewsResult.ResultType)" -ForegroundColor $(if($ewsResult.ResultType -eq "Success"){"Green"}else{"Red"})
Write-Host "`nScript voltooid." -ForegroundColor Cyan