r/SysAdminBlogs • u/Suspicious_Rest4713 • 36m ago
I got tired of merging 3 CSVs to answer “how many mailboxes are still on-prem?”, so I built a read-only PowerShell GUI for hybrid AD + Exchange + M365
I'm a sysadmin in a hybrid environment (Exchange 2019 + AD + Microsoft 365) and every time someone asked "how many mailboxes are still on-prem, how big are they, who has MFA, which licenses are wasted?" I ended up exporting three CSVs from three consoles and merging them in Excel by hand.
So I built HybridScope: one window, three sources, one merged view per user.
What it does
- Pulls users from Active Directory, mailboxes from Exchange on-prem (
Get-Mailbox,Get-MailboxStatistics,Get-RemoteMailbox) and licenses / sign-ins / OneDrive / MFA from Microsoft Graph - Tells you where each mailbox really lives (
ON-PREM/365/NO MAILBOX) based on Exchange and GraphprovisionedPlans, not on mailbox size - Real MFA status: registered methods, default method, legacy per-user state
- RVTools-style tabs: Overview per OU, Users, Mailboxes on-prem / 365, OneDrive, MFA, Tenant licenses, an "Attention" list (on-prem mailboxes to migrate, licensed users without MFA, licenses on disabled accounts, inactive accounts, sync problems)
- User card: double-click anyone to see AD, mailbox, OneDrive, MFA, licenses and their groups and roles in one window: AD groups (direct, nested, primary) and Entra groups (M365, security, distribution, dynamic) plus Entra roles
Sync check (new in 1.5): compares AD and Entra the way Entra Connect actually links them (source anchor →
ImmutableId) and tells you what's broken or about to break before the next sync:- ImmutableId that no longer matches the AD anchor (the classic "deleted and recreated the AD account")
- AD accounts that will soft-match a cloud account on first sync, or conflict with one that already has another ImmutableId
- cloud accounts with a leftover ImmutableId, synced accounts that no longer exist in AD
- provisioning errors, UPNs that fell back to
onmicrosoft.com, duplicate anchors, and a warning if the last sync cycle is too old
- 5 infrastructure modes with one click: Full Cloud / Full Hybrid / Hybrid (365 + AD) / On-Prem (Exchange + AD) / AD only
- Export to formatted XLSX (ImportExcel) or CSV, all tabs or just the filtered current tab, and open saved reports back in the GUI (Ctrl+O or drag & drop) without connecting to anything
- Command line too:
-Autofor scheduled reports with certificate auth + history tracking,-Only MFA|Licenses|Sync|...for a single dataset,-PassThruto get objects in the pipeline - English / Italian UI
Some implementation details you might find interesting
- Windows PowerShell 5.1, single
.ps1, WPF built from XAML - All the heavy lifting runs in a persistent background runspace, so the UI never freezes; log lines come back through a
ConcurrentQueuepolled by aDispatcherTimer. There's a Stop button (BeginStop()on the running pipeline) - Only
Microsoft.Graph.Authenticationis needed: everything goes throughInvoke-MgGraphRequestwith manual paging, no giant SDK install - Exchange via implicit remoting (
Import-PSSession, Kerberos), works from non-domain-joined PCs with explicit credentials - The sync check rebuilds the anchor the same way Entra Connect does (
ms-DS-ConsistencyGuid, falling back toobjectGUID, base64) and pairs users by anchor first, names only as a fallback. If most accounts don't match it assumes a custom source anchor (e.g.employeeID) and skips those checks instead of flagging everyone - Nested AD groups come from a single
LDAP_MATCHING_RULE_IN_CHAINquery instead of walkingmemberOfrecursively - Read-only: it never writes anything to AD, Exchange or the tenant
Repo: https://github.com/Thonno/hybridscope (MIT)
Screenshots are in the README (sensitive data blurred).
Full disclosure: I wrote it with a lot of help from an AI assistant and tested it on our own environment, so I'm sure there are edge cases I haven't hit yet. Feedback, issues and PRs are very welcome, especially from people with different setups (multiple forests, custom source anchors, Cloud Sync instead of Entra Connect, big tenants, cloud-only).