Top 7 PowerShell Scripts Every Office 365 Admin Should Use Weekly

Top 7 PowerShell Scripts Every Office 365 Admin Should Use Weekly

At Techatix, we believe in empowering IT administrators and businesses with efficient, scalable solutions. PowerShell is one such tool—an essential asset for anyone managing Microsoft 365 environments.

Whether you’re managing users, licenses, or mailboxes, automating tasks with PowerShell can save hours of manual work every week.

In this article, we’ll walk you through 7 essential PowerShell scripts every Office 365 admin should have in their weekly toolkit.


⚙️ 1. List All Licensed Users

Why it matters: Spot underutilized or abandoned accounts.

Get-MsolUser -All | Where-Object {$_.IsLicensed -eq $true} | Select-Object DisplayName, UserPrincipalName, Licenses

👤 2. Identify Inactive Users (No Login in 30+ Days)

Why it matters: Clean up unused accounts and reduce license costs.

Connect-MgGraph -Scopes "AuditLog.Read.All"
Get-MgUser | Where-Object {($_.SignInActivity.LastSignInDateTime -lt (Get-Date).AddDays(-30))} | Select-Object DisplayName, UserPrincipalName

📧 3. List Users with Mailbox Forwarding Enabled

Why it matters: Detect data exfiltration risks.

Get-Mailbox -ResultSize Unlimited | Where-Object {$_.ForwardingSMTPAddress -ne $null} | Select-Object DisplayName, ForwardingSMTPAddress

📊 4. Check License Usage Summary

Why it matters: Avoid over- or under-licensing.

Get-MsolAccountSku | Select-Object AccountSkuId, ActiveUnits, ConsumedUnits

📋 5. Export All Distribution Lists and Members

Why it matters: Document communication channels.

Get-DistributionGroup | ForEach-Object {
    $group = $_.Name
    Get-DistributionGroupMember -Identity $_.Identity | 
    Select-Object @{Name="GroupName";Expression={$group}}, Name, PrimarySmtpAddress
}

🛡️ 6. List Admin Roles by User

Why it matters: Catch unauthorized privilege assignments.

Get-MsolRole | ForEach-Object {
    $role = $_
    Get-MsolRoleMember -RoleObjectId $role.ObjectId | 
    Select-Object @{Name="Role";Expression={$role.Name}}, EmailAddress
}

🔐 7. Check MFA Status for All Users

Why it matters: Strengthen your authentication layer.

Get-MsolUser -All | Select-Object DisplayName, UserPrincipalName, StrongAuthenticationRequirements

Final Thoughts

PowerShell isn’t just for advanced admins—it’s for any IT professional who wants to manage Microsoft 365 more efficiently and securely. These scripts help you stay proactive, reduce risk, and streamline operations.

💡 Techatix Tip: Use Task Scheduler or Azure Automation to run these scripts on a schedule.

Need help building out your own Microsoft 365 automation toolkit? Let’s connect. Techatix is here to simplify your cloud journey.


Stay Connected

Follow our blog for more hands-on guidance, tips, and best practices around Microsoft 365 and Azure.

#PowerShell #Office365 #Automation #TechatixTips #Microsoft365 #CloudAdmin