PowerShell script to extract Exchange Online data for your own AI analysis

A while ago I wrote a script that reads Microsoft 365 security information and exports it to a JSON data file. The idea is that you can take this data file and use it with your AI of choice. I have now developed a similar script but for Exchange Online information.

Screenshot 2026-02-01 213211

When you run the script it will connect to Exchange online and extract the information from a variety of locations

Screenshot 2026-02-01 213303

It will produce 2 output JSON files in the parent directory. The standard data file can be quite large, in the case above it is around 15MB. The other file produced is more ‘compact’ around 100 – 200KB

Screenshot 2026-02-01 213701

You can then take either of these JSON files and feed them into you AI system of choice. The above shows you the result when I fed it into Copilot Researcher.,

Screenshot 2026-02-01 214046

and I even got a nice Word document when I fed it into Claude online.

You can download the script here:

https://github.com/directorcia/Office365/blob/master/Analysis/Exchange/exo-extract.ps1

and find the documentation here:

https://github.com/directorcia/Office365/wiki/Extract-Exchange-Online-information

as well as a long prompt you can use with your Ai of choice here:

https://github.com/directorcia/Office365/blob/master/Analysis/Exchange/prompt-long.txt

Given that email systems are typically at the highest security risk, this script shoudl allow you to quickly and easily evaluate its posture as well as giving you a range of improvement suggestions.

Getting AI Foundry local working

blog

A while ago I wrote an article about a PowerShell script I wrote that will extract JSON security configuration data from a tenant and feed that into an agent I had created using Azure AI foundry. That articles is here:

https://blog.ciaops.com/2026/01/22/combining-powershell-and-ai-for-m365-security-analysis/

I spend time on how I could get it working for anyone, given the model was inside my environment. I offered that access for free and have had no real takers.

Ok, I thought, maybe it ie because people are uncomfortable unloading private security data into ‘my model’, so then I created a script that just extracts the security configuration data, which you can find here:

https://blog.ciaops.com/2026/01/23/powershell-script-to-extract-m365-security-data-for-your-own-ai-analysis/

This way you can take that configuration data, along with some prompts I also provided, and feed that into your AI wherever that may be. When you do this with the Essential 8 prompt I provided the results look like this:

https://blog.ciaops.com/2026/01/25/essential-8-ai-report-via-powershell/

My next step, for those who may also desire their AI model to be local, was to look at Microsoft Foundry Local. This allows you to use your local compute resources (CPU, GPU and NPU if you have it) and run AI model on that machine.

First in the process is to instal lFoundry local which you can do at the command prompt via:

winget install Microsoft.FoundryLocal

next you need to select a model you wish to use. You can find all the models here:

https://www.foundrylocal.ai/models

Initially, I tried Phi 4 but couldn’t get it to load. This probably due to it size and lack of resources I have locally on my device. Instead I went for phi-4-mini. You download the model you wish via the command:

foundry model download phi-4-mini

when I ran this I actually got the phi-4-mini-instruct

Screenshot 2026-02-01 082356

You’ll also see that I got the version that runs on my GPU. The card for this model is here:

Screenshot 2026-02-01 082530

To actually get this model to run I used the command:

foundry model run phi-4-mini

and after a few moments I was greeted with:

Screenshot 2026-02-01 082717

so I typed in the following prompt and got the following answer:

Screenshot 2026-02-01 082856

So, it works as expected.

When I do prompt the local model I see my GPU utilisation spike like so:

Screenshot 2026-02-01 083943

Some observations so far about running local AI model

– Foundry local makes it pretty easy to get started with Ai models on yoru device

– It consumes significant local compute resources to run even the most basic AI model locally

– It is slow

– The results to prompts are limited

– It is all command line based

Now, that doesn’t mean local AI models don’t have a place and won’t improve but seeing the performance of these local models compared the online versions give you an appreciation for how much compute the online versions must have behind them! It has also demonstrated to me, finally, the reason that you may desire a device with a local NPU processor. I would expect to see some AI models pushed locally and connected back to online AI services in the future, so I now get the point of having a local NPU on the device. Would be interesting to test Foundry Local on a device with an NPU to see how much better it perform better if at all?

With Foundry Local now up and running on my machine, the next challenge is to try and create a script that again extract security information from Microsoft 365 but then feed it into the Foundry Local AI rather than an online model to see what the output and performance is like.

In short, I now see better what running local AI looks like but from what I see, it still needs a significant amount of compute to make sense when compared to anything online. It will be interesting to compare the online AI analysis of Microsoft 365 security data with local AI analysis. I think that will give me a much better appreciate for the value of a ‘business’ implementation of local AI services.

CIA Brief 20260131

image

Splitting single-tenant Microsoft Defender XDR Sentinel logs in multiple company scenarios –

https://techcommunity.microsoft.com/blog/coreinfrastructureandsecurityblog/splitting-single-tenant-…

SharePoint Showcase highlights: Copilot and agents governance and security essentials for admins –

https://techcommunity.microsoft.com/blog/microsoft365insiderblog/sharepoint-showcase-highlights-cop…

What’s New in Microsoft 365 Copilot | January 2026 –

https://techcommunity.microsoft.com/blog/microsoft365copilotblog/what%E2%80%99s-new-in-microsoft-36…

Turning threat reports into detection insights with AI –

https://www.microsoft.com/en-us/security/blog/2026/01/29/turning-threat-reports-detection-insights-…

Silicon to Systems: What powers Microsoft’s AI Infrastructure –

https://www.youtube.com/watch?v=zFqxwv-fiWI

Microsoft Azure Maia 200: Scott Guthrie EVP –

https://www.youtube.com/watch?v=bGecvPR2QWo

Upcoming Conditional Access change: Improved enforcement for policies with resource exclusions –

https://techcommunity.microsoft.com/blog/microsoft-entra-blog/upcoming-conditional-access-change-im…

Microsoft Purview | Data Security Triage Agent in DLP –

https://www.youtube.com/watch?v=yZQKnvSV3B0

Microsoft Defender for Office 365 | Mail Bombing and Mixed-Mode Attack Protection –

https://www.youtube.com/watch?v=rXGsQpqCWD4

The 6 pillars that will define agent readiness in 2026 –

https://www.microsoft.com/en-us/microsoft-copilot/blog/copilot-studio/the-6-pillars-that-will-defin…

UPDATE: New timeline for transitioning Sentinel experience to Defender portal –

https://techcommunity.microsoft.com/blog/microsoftsentinelblog/update-new-timeline-for-transitionin…

New Microsoft Data Security Index report explores secure AI adoption to protect sensitive data –

https://www.microsoft.com/en-us/security/blog/2026/01/29/new-microsoft-data-security-index-report-e…

General availability of source specific filters in Copilot Search –

https://techcommunity.microsoft.com/blog/microsoft365copilotblog/general-availability-of-source-spe…

Trust DigiCert Global Root G2 Certificate Authority to Avoid Exchange Online Email Disruption –

https://techcommunity.microsoft.com/blog/exchange/trust-digicert-global-root-g2-certificate-authori…

Voice in Microsoft 365 Copilot – Hands-Free Productivity –

https://www.youtube.com/watch?v=aeFpj-Ea3iY

Conditional Access for Agent Identities in Microsoft Entra –

https://techcommunity.microsoft.com/blog/coreinfrastructureandsecurityblog/conditional-access-for-a…

More control over proofing language in OneNote on Windows –

https://techcommunity.microsoft.com/blog/microsoft365insiderblog/more-control-over-proofing-languag…

Agent Mode is Here: Build & Edit Spreadsheets with Copilot in Excel –

https://www.youtube.com/watch?v=uDv8B_N_V1A

Advance Your SOC Skills with the Power of Microsoft Sentinel data lake and graph –

https://techcommunity.microsoft.com/blog/microsoft-security-blog/advance-your-soc-skills-with-the-p…

Updated Exchange Online SMTP AUTH Basic Authentication Deprecation Timeline –

https://techcommunity.microsoft.com/blog/exchange/updated-exchange-online-smtp-auth-basic-authentic…

St. Luke’s saves nearly 200 hours monthly with AI-powered Security Copilot agents –

https://www.youtube.com/watch?v=FGsZWFMsS_g

Microsoft 365 Accessibility, a year in review: Building accessible experiences with support from AI –

https://techcommunity.microsoft.com/blog/microsoft365insiderblog/microsoft-365-accessibility-a-year…

Accelerating Microsoft 365 Copilot Adoption with Automated Readiness Assessment –

https://techcommunity.microsoft.com/blog/microsoft365copilotblog/accelerating-microsoft-365-copilot…

From runtime risk to real‑time defense: Securing AI agents –

https://www.microsoft.com/en-us/security/blog/2026/01/23/runtime-risk-realtime-defense-securing-ai-…

After hours

Alex Honnold BEST MOMENTS Free Soloing Taipei 101 – https://www.youtube.com/watch?v=KkVZm5UuXIs

Editorial

If you found this valuable, the I’d appreciate a ‘like’ or perhaps a donation at https://ko-fi.com/ciaops. This helps me know that people enjoy what I have created and provides resources to allow me to create more content. If you have any feedback or suggestions around this, I’m all ears. You can also find me via email director@ciaops.com and on X (Twitter) at https://www.twitter.com/directorcia.

If you want to be part of a dedicated Microsoft Cloud community with information and interactions daily, then consider becoming a CIAOPS Patron – www.ciaopspatron.com.

Watch out for the next CIA Brief next week

New publication–Copilot Training & User Enablement Playbook for MSPs

Screenshot 2026-01-27 133052

https://directorcia.gumroad.com/l/flxnlj

Copilot Training & User Enablement Playbook for MSPs

Unlock the True Value of Microsoft 365 Copilot for Your Clients

The “Copilot Training & User Enablement Playbook for MSPs” is the definitive guide for Managed Service Providers who want to deliver not just Copilot deployments, but real, measurable outcomes for their clients. This comprehensive playbook empowers MSPs to transform Copilot from a shelfware add-on into a daily productivity engine—ensuring clients see rapid ROI, higher user satisfaction, and a competitive edge.

What’s Inside?
  • End-to-End Enablement Program: Step-by-step instructions for designing and delivering a structured Copilot training and change management program, including interactive workshops, ongoing coaching, and promotional strategies.

  • Ready-to-Use Collateral: Templates for reference guides, cheat sheets, workshop agendas, and communication materials that can be quickly customized for any client.

  • Proven Adoption Tactics: Practical advice on driving mindset shifts, securing executive sponsorship, and celebrating early wins to build momentum and sustain usage.

  • Pricing Models & Service Bundles: Clear guidance on how to package, price, and position your training services for maximum value and recurring revenue.

  • AI Center of Excellence Blueprint: A roadmap for offering ongoing support, Q&A clinics, and advanced user enablement as a premium retainer service.
Why Purchase This Playbook?
  • Accelerate Client ROI: Ensure your clients realize the full value of their Copilot investment—studies show that structured training and change management dramatically increase productivity and adoption rates.

  • Differentiate Your MSP: Stand out from competitors who simply “drop off” technology. This playbook positions you as a strategic partner, not just a software reseller.

  • Drive Real Outcomes: Move beyond installation to deliver tangible business results—like reduced document prep time, improved collaboration, and a culture of innovation.

  • Reusable, Scalable Assets: Save time and boost margins with ready-made, customizable materials and a repeatable delivery model.

  • Future-Proof Your Offering: Stay ahead with up-to-date best practices, ongoing support models, and strategies for evolving client needs.
Who Should Buy?
  • MSPs seeking to add high-value, high-margin services to their portfolio.

  • IT consultants and trainers responsible for Microsoft 365 Copilot rollouts.

  • Organizations that have deployed Copilot but struggle with low user adoption.


Don’t just deploy Copilot—make it indispensable.
Purchase the “Copilot Training & User Enablement Playbook for MSPs” and become the partner your clients trust to unlock the full power of AI in their workplace.

Now included with MSP AI Playbook bundle – https://directorcia.gumroad.com/l/mspaipb

See all the titles available at – https://directorcia.gumroad.com/

Need to Know podcast–Episode 359

I am joined by Andrew and Tim from Sherpatech to discuss updates and new challenges in the insurance market. If you missed last year’s episode you’ll find it here Episode 338 – Ensure to Insure. We discuss what impact AI is likely to have and how the insurance market is shaping up for 2026. I also have a few interesting updates and information from the Microsoft cloud for this first episode of 2026. So listen along and enjoy!

Brought to you by www.ciaopspatron.com

you can listen directly to this episode at:

https://ciaops.podbean.com/e/episode-359-reinsurance/

Subscribe via iTunes at:

https://itunes.apple.com/au/podcast/ciaops-need-to-know-podcasts/id406891445?mt=2

or Spotify:

https://open.spotify.com/show/7ejj00cOuw8977GnnE2lPb

Don’t forget to give the show a rating as well as send me any feedback or suggestions you may have for the show.

Resources

Explore the tools, communities, and content mentioned in this episode:

Show Notes

‘AI adoption is accelerating, but confidence is collapsing’: The more workers use AI, the less they trust it. Baby boomers show a 35% drop

Data Security Posture Management for AI | Microsoft Community Hub

GitHub Copilot CLI

Bringing work context to your code in GitHub Copilot – Microsoft for Developers

PowerShell script to extract M365 security data for your own AI analysis – CIAOPS

Essential 8 AI report via PowerShell – CIAOPS

Unlocking Microsoft 365 Security: How I Automated AI-Powered Risk Analysis with PowerShell

YouTube

Microsoft and Mercedes-AMG PETRONAS F1 Team unite to drive innovation from factory to circuit – Source

Microsoft OneDrive, a year in review: AI-powered file management and smarter collaboration

Demystifying Exchange Online Mailbox Quotas | Microsoft Community Hub

SherpaTech

Insurance Health Check

MSP/ IT Professional Insurance Quote and Policy portal

Insurance Checklists

Unlocking Microsoft 365 Security: How I Automated AI-Powered Risk Analysis with PowerShell

Video URL – https://www.youtube.com/watch?v=gyPXlI6GHCo

In this video, I walk you through my exclusive PowerShell script that transforms Microsoft 365 security management. Watch as I extract real-time security data from my Microsoft 365 tenant, summarize it, and seamlessly upload it to a custom AI Foundry agent powered by GPT-5. You’ll see how I authenticate using Azure AD, leverage model routing for the best AI analysis, and generate a detailed, actionable HTML security report—complete with risk assessments, prioritized recommendations, and remediation guides. This tool is available only to subscribers, so if you want to supercharge your Microsoft 365 security with AI automation, this is a must-watch! Drop your questions in the comments and discover what’s possible when PowerShell meets next-gen AI. See the blog post at – https://blog.ciaops.com/2026/01/22/co…