How gerenios/aadinternals works
Project type and purpose
• AADInternals is an open-source PowerShell module/CLI toolkit for administering Azure AD and Office 365.
• It wraps dozens of discrete “features” (ADFS, MFA, GraphAPI, AzureManagementAPI, Teams, SPO, etc.) into a single module.
File structure
• Top-level files:
• AADInternals.psd1 (module manifest)
• AADInternals.psm1 (module entry point)
• config.json (global configuration)
• any_sts.pfx (certificate for service-to-service auth)
• LICENSE.md, README.md
• Feature scripts: each feature has two files:
• FeatureName.ps1 — the public cmdlet definitions / entry functions
• FeatureName_utils.ps1 — shared helper functions (HTTP calls, data parsing)
• No frontend; it lives entirely as a PS module loaded into a PowerShell host.
README for additional insights
• Confirms installation via Install-Module.
• Purpose statement: “administering Azure AD and Office 365.”
Main components
a. PowerShell Host / User CLI
b. AADInternals Module Layer
– Module manifest (psd1) & entry script (psm1)
– Feature scripts (e.g., GraphAPI.ps1, MFA.ps1, Teams.ps1)
– Utility scripts (e.g., GraphAPI_utils.ps1, MFA_utils.ps1)
– config.json and any_sts.pfx for authentication settings
c. External Services
– Azure AD endpoints (OAuth2, token service)
– Microsoft Graph API & AAD Graph API
– Azure Resource Manager APIs
– Office 365 service endpoints (Teams, SharePoint Online, Exchange)
– On-premises components if used (ADFS, DCaaS, HybridHealth)
d. SDK / Library Dependencies
– Microsoft.Identity.Client (used internally by utils to acquire tokens)
– .NET assemblies (IdentityModel.Abstractions) loaded by PowerShell
Relationships and interactions
• User enters a cmdlet in PowerShell → PowerShell Host loads AADInternals module → the cmdlet’s .ps1 file invokes functions in its corresponding utils file → utils handle authentication (read config.json, load any_sts.pfx) → utils call underlying SDK or directly invoke REST endpoints → external service (Azure AD/ Graph/Office365) responds → utils parse response and return .NET objects or PSObjects back to the cmdlet → cmdlet formats output for the user.
• All feature scripts share common logic (CommonUtils.ps1) for logging, error handling, HTTP wrappers.
Architectural patterns and principles
• Layered: Presentation (CLI), Module Entry, Feature Commands, Shared Utilities, External Services.
• Plugin-style: each feature is self-contained in its own pair of .ps1 files, making it easy to add new features.
• Configuration-driven: config.json + certificate control how authentication is performed.
• DRY utilities: common HTTP, token management, and XML/JSON parsing live in “_utils” files.