10 Most Useful PowerShell Commands for Office 365 Admins

10 Most Useful PowerShell Commands for Office 365 Admins - Admin Center

PowerShell isn’t just a tool for Office 365 admins; it’s a game-changer. It unlocks efficiency, grants deep insights, and empowers you to take control of your environment. So, unleash the power within and discover how PowerShell can transform your Office 365 administration into a streamlined, efficient, and rewarding experience.

User Management:

  1. Get-MsolUser: Retrieves details about Office 365 users. For example, Get-MsolUser -Filter {Alias -eq “JohnDoe”} shows info for John Doe.
  2. Set-MsolUserPassword: Resets or sets a new password for a user. Use Set-MsolUserPassword -UserPrincipalName “JaneDoe@contoso.com” -NewPassword “StrongP@ssw0rd” to reset Jane’s password.
  3. Remove-MsolUser: Removes a user from your Office 365 tenant. Be cautious! Use Remove-MsolUser -UserPrincipalName “InactiveUser@contoso.com” with caution.

Group Management:

  1. Get-MsolGroup: Retrieves details about Office 365 security groups. Get-MsolGroup -Name “MarketingTeam” shows info for the Marketing Team group.
  2. Add-MsolGroupMember: Adds a user to a group. Add-MsolGroupMember -Group “SalesTeam” -Member “NewUser@contoso.com” adds NewUser to the Sales Team group.
  3. Remove-MsolGroupMember: Removes a user from a group. Use Remove-MsolGroupMember -Group “HR” -Member “LeavingEmployee@contoso.com” to remove a leaving employee.

SharePoint Online:

  1. Connect-SPOService: Connects to your SharePoint Online environment. Remember to run $cred = Get-Credential before this command for authentication.
  2. Get-SPOSite: Lists all SharePoint site collections in your tenant. Use Get-SPOSite | Where {$_.Url -like “https://contoso.sharepoint.com/*”} to filter by URL.
  3. Remove-SPOUser: Removes a user from all SharePoint sites in your tenant. Remove-SPOUser -LoginName “RetiredUser@contoso.com” removes the user from all sites.

Additional Utilities:

  1. Search-Mailbox: Searches email content across all mailboxes in your tenant. Powerful for investigating issues! Use Search-Mailbox -Identity “SuspiciousUser@contoso.com” -Keywords “Confidential” to search for keywords in a specific user’s mailbox.

Read more: Microsoft Learn https://learn.microsoft.com/en-us/powershell/

Previous Article

Unlock your Creativity with Copilot and Microsoft Designer

Next Article

SharePoint Online Permission Management and File Sharing for Beginners

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Subscribe to Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Powered by Amail.