From d2a7cf888237c1f624f87fbaa794bc791615d131 Mon Sep 17 00:00:00 2001 From: Martien Date: Wed, 4 Mar 2026 15:34:43 +0100 Subject: [PATCH] Add Exchange/Check-HybridOAuth-ExchangeOnline.ps1 --- Exchange/Check-HybridOAuth-ExchangeOnline.ps1 | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Exchange/Check-HybridOAuth-ExchangeOnline.ps1 diff --git a/Exchange/Check-HybridOAuth-ExchangeOnline.ps1 b/Exchange/Check-HybridOAuth-ExchangeOnline.ps1 new file mode 100644 index 0000000..f4ef15d --- /dev/null +++ b/Exchange/Check-HybridOAuth-ExchangeOnline.ps1 @@ -0,0 +1,54 @@ +# ============================================================ +# 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 \ No newline at end of file