office 365 cmd

Office 365 Cmd Jun 2026

(Get-MgUser -UserId "ID" -Property AssignedLicenses).AssignedLicenses Managing Exchange Online via Command Line

You need to sign in and grant permissions. For general user management, use: Connect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All"

Run this command to get the core tools: Install-Module Microsoft.Graph -Scope CurrentUser office 365 cmd

Most commands can be piped to a file for reporting using | Export-Csv -Path "C:\Reports\Users.csv" -NoTypeInformation .

Navigate to the Office installation folder (e.g., C:\Program Files\Microsoft Office\Office16 ) and run: cscript ospp.vbs /dstatus (Get-MgUser -UserId "ID" -Property AssignedLicenses)

To prevent a user from signing in (disable the account):

Get-Mailbox -Identity "user" | Select-Object UsageLocation, PrimarySmtpAddress Best Practices for Command Line Management use: Connect-MgGraph -Scopes "User.ReadWrite.All"

Import-Csv "C:\Temp\DisableUsers.csv" | ForEach-Object Update-MgUser -UserId $_.UserPrincipalName -AccountEnabled:$false Write-Host "Disabled: $($_.UserPrincipalName)"