In this episode of M365.fm, Mirko Peters shows how to drop legacy PowerShell modules like MSOnline and AzureAD and move to a clean, REST‑first pattern with Microsoft Graph that runs anywhere — Windows, Linux, containers, and CI/CD.
WHAT YOU WILL LEARN
- The API‑first, module‑free PowerShell pattern for Microsoft Graph
- Three real‑world auth flows (device code, certificate, Managed Identity) and when to use each
- How to build scripts that survive Linux runners, containers, and cloud automation environments
- How to implement paging, throttling, and retries correctly with Invoke‑RestMethod
- A simple Graph “gotcha” that silently breaks most scripts — and how to avoid it forever
- Why security, RBAC, and least‑privilege app registrations love this approach
- How to sell this shift to your security team and leadership
THE CORE INSIGHT
Modules lag, Graph is always first. If a feature exists in Microsoft 365, it lands in Microsoft Graph before it ever shows up in a PowerShell module — if it shows up at all.
By going REST‑first, you stop fighting module versions, dependencies, and platform differences and instead build small, predictable scripts that talk to Graph directly.
Tokens replace credentials, short‑lived access replaces shared service accounts, and your scripts suddenly become audit‑friendly and automation‑ready.
This episode argues that the future of serious automation in Microsoft 365 is PowerShell + REST + Graph — not another generation of fragile modules.
WHY POWERSHELL WITHOUT MODULES WORKS
- Graph is the single, consistent API surface behind the Microsoft 365 portals you already use
- PowerShell Core plus Invoke‑RestMethod works on Windows, Linux, containers, GitHub Actions, and Azure Functions
- Auth is standardized: OAuth2, certificates, and Managed Identity instead of stored passwords
- You can control scopes and app permissions with precision, then review them on a schedule
- Observability improves: every call has request IDs and correlation IDs in standard logs
- You reduce your dependency on third‑party module maintainers and “works on my machine” setups
KEY TAKEAWAYS
- Stop importing legacy modules for new automation — design against Microsoft Graph directly
- Use device code auth for local dev, certificates for headless jobs, and Managed Identity for Azure‑hosted workloads
- Centralize retry, pagination, and throttling handling into a few reusable helpers
- Keep permissions tight: grant only the Graph roles each job actually needs
- Treat tokens as disposable, auditable access — not as a convenience hack
- Design your scripts for CI/CD and cloud from day one, not just for your laptop
WHO THIS EPISODE IS FOR
This episode is ideal for Microsoft 365 admins, automation engineers, DevOps teams, and cloud architects who rely on PowerShell for identity, Intune, and tenant operations.
If your scripts still import MSOnline or AzureAD, or if CI/CD runners keep breaking your module‑based automation, this conversation will show you how to modernize with a Graph‑first approach.
TOPICS COVERED
- PowerShell + REST + Microsoft Graph as a universal pattern
- Device code, certificate, and Managed Identity auth flows in practice
- Handling paging, throttling, and retries with Invoke‑RestMethod
- Enterprise‑grade Intune device cleanup without any modules
- Security, RBAC, and observability benefits of token‑based automation
- Common pitfalls when migrating from modules to Graph and how to avoid them
ABOUT THE HOST
Mirko Peters is a Microsoft 365 consultant and digital workplace architect focused on building cloud‑native, automation‑ready environments on the Microsoft stack.
Through M365.fm, Mirko shares practical patterns, governance approaches, and real‑world scripts that help IT teams move from legacy modules to modern, Graph‑first automation.
Become a supporter of this podcast: https://www.spreaker.com/podcast/m365-fm-modern-work-security-and-productivity-with-microsoft-365--6704921/support.