Monday, May 25, 2026

Microsoft 365 Workloads – Daily Used PowerShell Commands

 Microsoft 365 Workloads – Daily Used PowerShell Commands

As an M365 Administrator, SharePoint Administrator, or Collaboration Engineer, these are the most frequently used PowerShell commands across major Microsoft 365 workloads.

 

1. Microsoft Entra ID (Azure AD)

Module:

Microsoft.Graph

Connect

Connect-MgGraph -Scopes "User.Read.All","Group.Read.All"

Get Users

Get-MgUser

Get Specific User

Get-MgUser -UserId user@contoso.com

Create User

New-MgUser

Disable User

Update-MgUser -UserId user@contoso.com -AccountEnabled:$false

Get Groups

Get-MgGroup

Add User to Group

New-MgGroupMember

Remove User from Group

Remove-MgGroupMemberByRef

Get Licenses

Get-MgSubscribedSku

Assign License

Set-MgUserLicense

 

2. SharePoint Online

SharePoint Online

Module:

Microsoft.Online.SharePoint.PowerShell
PnP.PowerShell

Connect

Connect-SPOService -Url https://tenant-admin.sharepoint.com

Get Tenant Settings

Get-SPOTenant

Get All Sites

Get-SPOSite -Limit All

Create Site

New-SPOSite

Remove Site

Remove-SPOSite

Restore Site

Restore-SPODeletedSite

Get Site Admins

Get-SPOUser

Set Site Collection Admin

Set-SPOUser

Lock Site

Set-SPOSite -LockState ReadOnly

External Sharing

Set-SPOSite -SharingCapability Disabled

 

PnP PowerShell

Connect

Connect-PnPOnline -Url https://tenant.sharepoint.com -Interactive

Get Libraries

Get-PnPList

Create Library

New-PnPList

Upload File

Add-PnPFile

Download File

Get-PnPFile

Create Column

Add-PnPField

Create Content Type

Add-PnPContentType

 

3. Exchange Online

Exchange Online

Module:

ExchangeOnlineManagement

Connect

Connect-ExchangeOnline

Get Mailboxes

Get-Mailbox

Get Mailbox Statistics

Get-MailboxStatistics

Create Shared Mailbox

New-Mailbox -Shared

Get Shared Mailboxes

Get-Mailbox -RecipientTypeDetails SharedMailbox

Add Mailbox Permission

Add-MailboxPermission

Remove Mailbox Permission

Remove-MailboxPermission

Create Distribution Group

New-DistributionGroup

Get Distribution Groups

Get-DistributionGroup

Add Group Member

Add-DistributionGroupMember

Mail Trace

Get-MessageTrace

Mail Flow Rules

Get-TransportRule

 

4. Microsoft Teams

Microsoft Teams

Module:

MicrosoftTeams

Connect

Connect-MicrosoftTeams

Get Teams

Get-Team

Create Team

New-Team

Add User

Add-TeamUser

Remove User

Remove-TeamUser

Get Team Members

Get-TeamUser

Get Channels

Get-TeamChannel

Create Channel

New-TeamChannel

Get Teams Policies

Get-CsTeamsMeetingPolicy

 

5. OneDrive for Business

OneDrive for Business

Uses SPO commands because OneDrive is built on SharePoint.

Get OneDrive Sites

Get-SPOSite -IncludePersonalSite $true

Get Specific OneDrive

Get-SPOSite -Identity https://tenant-my.sharepoint.com/personal/user

Set Storage Quota

Set-SPOSite

Restore OneDrive

Restore-SPODeletedSite

 

6. Microsoft Purview (Compliance Center)

Microsoft Purview

Module:

ExchangeOnlineManagement
IPPSSession

Connect

Connect-IPPSSession

Get Retention Policies

Get-RetentionCompliancePolicy

Get Retention Labels

Get-ComplianceTag

Get DLP Policies

Get-DlpCompliancePolicy

Get DLP Rules

Get-DlpComplianceRule

Content Search

Get-ComplianceSearch

Start Search

Start-ComplianceSearch

Audit Log Search

Search-UnifiedAuditLog

 

7. Microsoft Intune

Microsoft Intune

Module:

Microsoft.Graph

Connect

Connect-MgGraph

Managed Devices

Get-MgDeviceManagementManagedDevice

Compliance Policies

Get-MgDeviceManagementDeviceCompliancePolicy

Configuration Profiles

Get-MgDeviceManagementDeviceConfiguration

Remote Wipe

Invoke-MgDeviceManagementManagedDeviceWipe

 

8. Power Platform

Power Apps

Module:

Microsoft.PowerApps.Administration.PowerShell

Connect

Add-PowerAppsAccount

Get Apps

Get-AdminPowerApp

Get Environments

Get-AdminPowerAppEnvironment

Get Connectors

Get-AdminPowerAppConnector

 

9. Power Automate

Get Flows

Get-AdminFlow

Get Flow Details

Get-Flow

Disable Flow

Disable-AdminFlow

 

10. Microsoft 365 Groups

Get Groups

Get-UnifiedGroup

Create Group

New-UnifiedGroup

Add Member

Add-UnifiedGroupLinks

Remove Member

Remove-UnifiedGroupLinks

 

11. Licensing

View Licenses

Get-MgSubscribedSku

View User Licenses

Get-MgUserLicenseDetail

Assign License

Set-MgUserLicense

Remove License

Set-MgUserLicense

 

12. Security & Defender

Microsoft Defender for Office 365

Connect

Connect-ExchangeOnline

Safe Attachments

Get-SafeAttachmentPolicy

Safe Links

Get-SafeLinksPolicy

Anti-Spam Policies

Get-HostedContentFilterPolicy

Quarantine Messages

Get-QuarantineMessage

 

Daily Commands Used Most by M365 Administrators

Workload

Daily Commands

Entra ID

Get-MgUser, Get-MgGroup, Set-MgUserLicense

SharePoint Online

Get-SPOSite, Get-SPOUser, Set-SPOSite

Exchange Online

Get-Mailbox, Get-MessageTrace, Add-MailboxPermission

Teams

Get-Team, Add-TeamUser, Get-TeamChannel

OneDrive

Get-SPOSite -IncludePersonalSite

Purview

Search-UnifiedAuditLog, Get-DlpCompliancePolicy

Intune

Get-MgDeviceManagementManagedDevice

Power Apps

Get-AdminPowerApp

Power Automate

Get-AdminFlow

Licensing

Get-MgSubscribedSku

Security

Get-QuarantineMessage


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.