office365 cmd

Office365 Cmd [hot] Today

powershell Then connect to Microsoft 365:

@echo off powershell -Command "Connect-MgGraph -Scopes 'User.Read.All'; Get-MgUser -Top 5 | Format-Table DisplayName,UserPrincipalName" pause For unattended scripts (app-only auth): office365 cmd

$securePassword = ConvertTo-SecureString "client_secret" -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential ("app@client-id", $securePassword) Connect-MgGraph -AccessToken (Get-MsalToken -ClientId "client-id" -TenantId "tenant-id" -ClientSecret "secret").AccessToken | Issue | Fix | |-------|-----| | Connect-ExchangeOnline fails | Run as admin; check TLS: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | | Graph auth errors | Request scopes explicitly: -Scopes "User.Read.All", "Mail.Send" | | Module not recognized | Install-Module -Name ModuleName -Force -AllowClobber | | Slow commands | Use -Top or -PageSize to limit results | 8. Quick Reference Card ┌─────────────────────┬──────────────────────────────────────────┐ │ Task │ Command │ ├─────────────────────┼──────────────────────────────────────────┤ │ Connect Exchange │ Connect-ExchangeOnline │ │ Connect Graph │ Connect-MgGraph │ │ List all users │ Get-MgUser -All │ │ Get user details │ Get-MgUser -UserId "user@domain.com" │ │ List groups │ Get-MgGroup │ │ Assign license │ Set-MgUserLicense │ │ Create user │ New-MgUser -DisplayName "..." ... │ │ Delete user │ Remove-MgUser -UserId "..." │ │ Get mailbox folders │ Get-EXOMailboxFolderStatistics │ │ Teams list │ Get-Team │ │ CLI login │ m365 login │ └─────────────────────┴──────────────────────────────────────────┘ Final Tip For daily admin tasks , use Microsoft Graph PowerShell SDK — it’s the future. For quick one-offs, CLI for Microsoft 365 works directly from CMD without PowerShell. powershell Then connect to Microsoft 365: @echo off

Save this post as a cheat sheet and adapt the commands to your tenant. For quick one-offs, CLI for Microsoft 365 works