Scripts
30 free PowerShell scripts for Microsoft 365 and Entra ID administration, email and endpoint security, BitLocker, and device management. Written for real-world IT work and shared for the community.
Every script is sanitised: real tenants, domains, and secrets are replaced with clearly-marked placeholders (likeyourtenant.onmicrosoft.com or <API_KEY>) that you set before running. Read each script first, test in a safe environment, and run at your own risk. Some make changes or need admin rights. Adapted scripts credit their original author.
Microsoft 365 & Entra ID
- M365 User & Security Report
Comprehensive Microsoft 365 audit: an Excel report of every mailbox (licences, MFA status, last logon, size, aliases, delegates) plus a text report of per-domain email security (MX, SPF, DKIM), licence counts, and risky findings like forwarding rules and admin-role holders. Note: uses the legacy MSOnline module, which Microsoft is retiring.
- Add All Users to a Security Group
Adds every member (non-guest) user in the tenant to an Entra ID security group you choose at runtime. Note: uses the legacy AzureAD module (being retired); Microsoft Graph is the successor.
- Enable & Enforce Legacy Per-User MFA
Sets legacy per-user MFA to Enabled then Enforced for all member users. Useful for small tenants not yet on Conditional Access. Note: uses the legacy MSOnline module, which Microsoft is retiring.
- Disable Legacy Per-User MFA
Clears legacy per-user MFA state for all member users, for example before migrating enforcement to Conditional Access. Note: uses the legacy MSOnline module, which Microsoft is retiring.
- Export Mailbox & Group Aliases
Exports every mailbox and Microsoft 365 group SMTP alias to CSV. Handy for finding which address is attached where.
- Add Users to Anti-Phishing Policy
Adds every mailbox user to the protected-users list of a Defender for Office 365 anti-phishing (impersonation) policy you select.
Email security & monitoring
- Send a Test Email over SMTP
Send a test email from PowerShell three ways: authenticated SMTP (TLS on port 587), an unauthenticated internal relay, or direct to a Microsoft 365 mail connector (the MX endpoint on port 25). Includes an MX-lookup helper. Handy for confirming a mail relay works and for security and relay testing.
- DKIM Selector Check
Queries the common DKIM selectors (default, s1/s2, selector1/2) for a domain via DNS and reports which records exist.
- Internal Email Volume Report
Reports the number of messages sent per internal user per day from Exchange Online message trace, exported to CSV. Note: Get-MessageTrace covers only the last 10 days and is being replaced by Get-MessageTraceV2.
- Dark Web Breach Check (HIBP)Adapted from CyberDrain (Kelvin Tegelaar)
Checks every user in a Microsoft 365 tenant against Have I Been Pwned and produces a searchable HTML plus CSV breach report. Needs a paid HIBP API key, and uses the legacy AzureAD module (being retired).
- Dark Web Breach Check: Partner Center editionAdapted from CyberDrain (Kelvin Tegelaar)
As above, with Microsoft Partner Center support so you can pick and scan any client tenant you manage. Needs a paid HIBP API key.
SharePoint reporting
- SharePoint External Users ReportO365Reports Team
Exports all external / guest users across SharePoint Online (site-wise or tenant-wide) to CSV.
- SharePoint External-Sharing Settings
Reports each SharePoint Online site's external-sharing capability (in plain English) along with last-modified date and storage usage, to CSV.
Endpoint security audit
- Endpoint Security Posture Audit
Collects a device security posture (local admins, inactive and passwordless accounts, RDP, firewall, Microsoft Defender for Endpoint, and BitLocker per drive) and writes it to JSON plus the console. No external database.
- Find Local Accounts with Blank Passwords
Lists any enabled local account that has a blank password, a common and dangerous misconfiguration.
BitLocker & device encryption
- Ensure BitLocker Protected (TPM + Entra backup)
Ensures the OS drive has a TPM protector and a recovery-password protector, resumes protection if off, and backs the recovery key up to Entra ID. Never prints the recovery key.
- BitLocker Status (one-line for RMM)
Outputs a single-line BitLocker status summary (protection, volume status, encrypted %) for any RMM monitor or condition to capture.
- Enable BitLocker on C:
Enables BitLocker encryption on the C: drive.
- Resume / Enable BitLocker Protection
Turns BitLocker protection on separately from the encryption process (for drives that are encrypted but with protection suspended).
- BitLocker Encryption Progress %
Reports the current BitLocker encryption percentage of a drive.
- Back Up BitLocker Key to Entra ID
Backs up the BitLocker recovery key for a drive to Entra ID.
- Check Device BitLocker State
Checks and reports the BitLocker state of the device.
- Check Intune BitLocker Policies
Lists the Intune device-configuration and compliance policies related to BitLocker, and their assignments. Note: relies on the deprecated Microsoft.Graph.Intune SDK and may need reworking for current tenants.
Windows configuration
- Set Power & Sleep Settings
Applies power and sleep settings (for example never sleep on AC power).
- Check Power & Sleep Settings
Reports the current power and sleep configuration.
- Enable Automatic Updates + Active Hours
Enables Windows automatic updates and sets active hours.
- Check Automatic Updates + Active Hours
Reports whether automatic updates are running and what active hours are set.
- Enable System Restore + Restore Point
Enables System Restore on the system drive and creates a restore point.
- Check System Restore Status
Reports whether System Restore is enabled (not supported on server operating systems).
Provisioning & setup
- Remove HP Bloatware
Removes HP preinstalled bloatware and support applications from a new HP device.