www.techtarget.com Open in urlscan Pro
104.18.18.71  Public Scan

Submitted URL: https://go.techtarget.com/r/302792486/47152004
Effective URL: https://www.techtarget.com/searchwindowsserver/tip/What-do-admins-need-to-know-about-the-CLI-for-Microsoft-365?utm_campaign...
Submission: On September 27 via manual from CA — Scanned from CA

Form analysis 1 forms found in the DOM

POST https://www.techtarget.com/search

<form action="https://www.techtarget.com/search" method="post" class="header-search">
  <label for="header-search-input" class="visuallyhidden">Search the TechTarget Network</label>
  <input class="header-search-input ui-autocomplete-input" id="header-search-input" autocomplete="off" type="text" placeholder="Search the TechTarget Network">
  <button aria-label="Search" class="header-search-submit"><i class="icon" data-icon="g"></i></button>
</form>

Text Content

3
Trending Now

Best practices for closing Office 365 compliance gapsDownload NowView All3
X
3Hello, these 3 documents have been trending and as a member they are free to
you.
 * 
   Best practices for closing Office 365 compliance gapsDownload Now
 * 
   Confluence vs. SharePoint: When to use which?Download Now
 * 
   Navigating the Data Current ReportDownload Now




SearchWindowsServer
Search the TechTarget Network
Login Register
Explore the Network
 * TechTarget Network
 * Cloud Computing
 * Enterprise Desktop
 * Virtual Desktop

 * SearchWindowsServer
 * * IT Ops & Infrastructure Management
   * Identity & Access Management
   * Messaging & Collaboration
   * Microsoft Cloud & Hybrid Services
   * Windows Server Management
   Other Content
    * News
    * Features
    * Tips
    * Webinars
    * 2023 IT Salary Survey Results
    * Sponsored Sites
    * More
       * Answers
       * Conference Guides
       * Definitions
       * Opinions
       * Podcasts
       * Quizzes
       * Tech Accelerators
       * Tutorials
       * Videos

 * Follow:
 * 
 * 
 * 
 * 
 * 


 * Home
 * IT operations and infrastructure management

Getty Images/iStockphoto

Getty Images/iStockphoto

Tip
Article 2 of 4
Part of: Advanced management methods for cloud-based Microsoft admins


CLI FOR MICROSOFT 365: A GUIDE FOR ADMINISTRATORS




THE OPTIONS TO MANAGE THE MICROSOFT 365 PLATFORM ARE SEEMINGLY ENDLESS, BUT THE
CLI FOR MICROSOFT 365 OFFERS DISTINCT ADVANTAGES FOR ADMINS IN THE ENTERPRISE.

 * Share this item with your network:
 * 
 * 
 * 
 * 
 * 

 * 
 * 
 *  * 
    * 
    * 
    * 


By
 * Liam Cleary, SharePlicity

Published: 14 Dec 2023

There is no shortage of management options for administrators who work with
Azure and Microsoft 365 services.

As IT professionals frequently resort to scripting to manage configurations and
automate tasks, the CLI for Microsoft 365 -- formerly known as the Office 365
CLI -- offers a compelling alternative to other methods, such as PowerShell
modules and Microsoft Graph. The CLI for Microsoft 365 is a standalone tool that
offers several advantages to help a busy IT staff, including cross-platform
support, expanded automation capabilities and simplified management of cloud
resources. Learn about the setup process then follow the examples to understand
how to use the CLI for Microsoft 365 for administrative jobs on the cloud
collaboration platform.




WHY DO ADMINS NEED A COMMAND-LINE INTERFACE?

A CLI offers interaction with a computer program through typed commands in a
terminal instead of a GUI. With a CLI, you can automate tasks, perform system
administration and run scripts more efficiently than a traditional GUI.

When you use a CLI with Microsoft 365 and Azure to manage cloud services using
text-based commands, you get several benefits:

 * Expanded automation capabilities.
 * Scripting interface.
 * Better control over complex tasks.
 * More efficient management and deployment of resources in the cloud.

You can handle most management jobs for Azure and Microsoft 365 in the
administration portals. However, some tasks require a script because the
functionality does not exist in the Azure or Microsoft 365 administration
portals. For example, you must execute commands to set a property within the
tenant to limit who can create a team in Microsoft Teams within Microsoft 365.
You can see the PowerShell here.


WHAT IS THE DIFFERENCE BETWEEN THE CLI FOR MICROSOFT 365 AND POWERSHELL?

The CLI for Microsoft 365 and PowerShell are command-line interfaces you can use
to manage Microsoft 365 and some Azure resources; however, they differ in
several ways.

The CLI for Microsoft 365 is a cross-platform command-line interface for
managing and automating tasks in Microsoft 365 and some components of Azure. It
provides a single unified login to Microsoft 365 workloads.

The CLI for Microsoft 365 gives you the ability to execute scripts and automate
everyday administrative tasks, simplifying the management and administration of
these services. It is limited in its management scope, but Microsoft updates it
frequently.

The CLI is built on top of Node.js and installs on Windows, macOS and Linux.

PowerShell is a command-line interface useful for management of Microsoft 365
and all Azure resources primarily within a Windows OS; however, using PowerShell
7, some modules are cross-platform and work on Windows, macOS and Linux.

PowerShell has an extensive scripting language and automation framework for
scripting. Microsoft and the community provide many PowerShell modules to extend
its functionality.


HOW TO START USING THE CLI FOR MICROSOFT 365

To use the CLI for Microsoft 365, install Node.js and then the CLI.

Microsoft tested the CLI for Microsoft 365 with Node.js version 6, but the
company advises using the latest Long Term Support (LTS) version. If you run
Docker containers, then you can also use a Docker image.

Next, launch into Node.js with a console, such as Windows Terminal, and use the
npm command to install the CLI for Microsoft 365.

Once installed, execute m365 version to see the currently installed version and
if CLI for Microsoft 365 works.

Next, connect to Microsoft 365. The CLI for Microsoft 365 supports several
authentication methods, including device code flow, username and password,
certificate, secret and standard browser authentication. The default
authentication flow uses the device approach. To authenticate this way, type
m365 login, and then complete the device flow.

After passing the authentication process, you can execute commands to manage
Microsoft 365 services and Microsoft Entra ID, formerly called Azure Active
Directory.

For example, to list all users on the Microsoft Entra ID tenant, you can type
the following:

# User list output in the default JSON format
m365 aad user list --output text

# User list output as TEXT
m365 aad user list --output csv

# User list output as MARKDOWN
m365 aad user list --output md

# User list output as CSV, displaying only 'DisplayName' and 'Mail' fields
m365 aad user list --properties "displayName,mail" --output csv

# User list output as TEXT, where the 'DisplayName' starts with 'Adele'
m365 aad user list --displayName Adele --output csv

All CLI for Microsoft 365 commands begin with m365 followed by the root object
services, such as teams and spo. You then add the specific object, such as team,
file and task. You then add actions such as add, get, list, remove or set.

Some further examples are the following:

# Retrieve all planner tasks
m365 planner task list

# Execute the active user detail report for the tenant
m365 tenant report activeuserdetail

# Add a content type
m365 spo contenttype add \
     --webUrl https://domain.sharepoint.com/sites/site \
     --name 'Content Type' –id
0x01007926A26D295BA842B947286090B7F67E \
     --group 'Content Type Group'

# Rename a SharePoint Online site
m365 spo site rename \
     --url https://domain.sharepoint.com/oldsite \
     --newUrl https://domain.sharepoint.com/newsite

# Apply a theme to a SharePoint Online site
m365 spo theme apply \
     --name Theme \
     --webUrl https://domain.sharepoint.com/sites/site \
     --sharePointTheme

# Create a new Team
m365 teams team add \
     --name "Team" \
     --description "Team Description"


HOW TO USE THE CLI FOR MICROSOFT 365 TO PERFORM ADMINISTRATIVE TASKS

You can combine commands in the CLI for Microsoft 365 to create scripts to
execute single or multiple tasks. Another option is to use PowerShell with the
CLI for Microsoft 365.

The advantage is there are no PowerShell modules to load because you use the CLI
for Microsoft 365 commands instead. The following PowerShell example removes all
Microsoft 365 groups:

$groups = m365 aad o365group list  -o json | ConvertFrom-Json
foreach ($group in $groups)
{
     Write-Host "Deleting: " $group.displayName
     m365 aad o365group remove --id $group.id –confirm
}

The following PowerShell example lists all members of all teams within Microsoft
Teams:

$output = @()
$teams = m365 teams team list -o json | ConvertFrom-Json
foreach($team in $teams)
{
     $users = m365 teams user list --teamId $team.id -o json | ConvertFrom-Json
foreach($user in $users)
     {
          $output += [PSCustomObject]@{
               "User ID"=$user.id
               "User Principal Name"=$user.userPrincipalName
               "Assigned Role"=$user.userType
               "Team ID"=$team.id
               "Team Name"=$team.displayName
          }
     }
     $output | Export-Csv `
          -Path "Teams-Members-Report.csv" `
          -NoTypeInformation
}

Combining the power of the CLI for Microsoft 365 with PowerShell creates a
powerful scripting approach that helps you, as an IT administrator, perform
tasks easier and faster.

Liam Cleary runs his own consulting company that helps customers work with
Microsoft 365 and Azure-based technologies. He specializes in internal and
external collaboration, document and records management, business process
automation and security implementation.

NEXT STEPS

An explanation of CLI, GUI and NUI



RELATED RESOURCES

 * AIOPs for Integrated Infrastructure Management –Webinar

DIG DEEPER ON IT OPERATIONS AND INFRASTRUCTURE MANAGEMENT

 * UK GOVERNMENT’S M365 USE UNDER SCRUTINY AFTER MICROSOFT’S ‘NO GUARANTEE OF
   SOVEREIGNTY’ DISCLOSURE
   
   
   By: Caroline Donnelly

 * HOW TO MANAGE MICROSOFT 365 GUEST USERS WITH POWERSHELL
   
   
   By: Liam Cleary

 * MICROSOFT PUSHES TEAMS OUT OF M365 AND O365 BUNDLE GLOBALLY
   
   
   By: Cliff Saran

 * TOP PUBLIC CLOUD PROVIDERS OF 2024: A BRIEF COMPARISON
   
   
   By: Brien Posey

Part of: Advanced management methods for cloud-based Microsoft admins

Article 2 of 4
Up Next
What's new in Microsoft Graph PowerShell v2?

The company overhauled the new version of its software development kit and
updated PowerShell modules that replace legacy methods for managing Microsoft's
cloud-based services.

CLI for Microsoft 365: A guide for administrators

The options to manage the Microsoft 365 platform are seemingly endless, but the
CLI for Microsoft 365 offers distinct advantages for admins in the enterprise.

Kusto Query Language primer for IT administrators

Administrators who use Microsoft cloud services, such as Microsoft Sentinel and
Microsoft 365, can learn how to pull information from those products with KQL
queries.

How to use Microsoft 365 DSC to avoid configuration drift

This configuration-as-code technology gives admins a way to automate tasks on
the Microsoft 365 tenant to keep settings locked in and avoid errors from manual
input.

Sponsored News
 * 5 Ways Real-World Data Accelerates Time-to-Value –Dell Technologies
 * Improving Operational Efficiencies: 4 Success Stories in Digital
   Transformation –Dell Technologies
 * Modernizing Microsoft SQL Server with a Multicloud-By-Design Approach –Dell
   Technologies
 * See More

Related Content
 * Use the admin center for some Office 365 ... – SearchWindowsServer
 * Working with PowerShell Secret Management and Secret ... –
   SearchWindowsServer
 * HC3 Checklist Helps Healthcare Sector Ensure Mobile ... – Healthtech Security


-ADS BY GOOGLE

Latest TechTarget resources
 * Cloud Computing
 * Enterprise Desktop
 * Virtual Desktop

Cloud Computing
 * 3 takeaways from the CompTIA Cloud+ certification exam
   
   The author of The Official CompTIA Cloud+ Instructor Guide and Student Guide
   shares his most interesting takeaways from the ...

 * 8 key steps of a cloud exit strategy
   
   If your cloud-based workloads and applications need to move back on premises,
   you'll need a plan. Start your reverse migration ...

 * Is cloud repatriation the only answer?
   
   Cloud repatriation should be a last resort, not a repudiation of the cloud.
   Do you know how to fully optimize cloud workloads to ...

Enterprise Desktop
 * How to repair Windows 11 with an ISO file
   
   While wiping and reinstalling via a clean install is the simplest way to fix
   a broken Windows 11 desktop, an ISO file repair can ...

 * Understanding how the Copilot+ PC program uses AI
   
   Organizations looking to boost productivity for key Windows users should
   learn what Copilot+ PCs can offer and what workflows the...

 * Assessing the competitors of Copilot for Microsoft 365
   
   There are numerous generative AI tools that focus on enhancing user
   productivity, so organizations should survey the market to ...

Virtual Desktop
 * What is the difference between Windows 10 vs. Windows 10 IoT?
   
   There are several key differences between Windows IoT and a regular Windows
   desktop OS, so organizations must compare these ...

 * Comparing AWS WorkSpaces vs. Azure Virtual Desktop
   
   AWS WorkSpaces and Azure Virtual Desktop are stable and mature platforms that
   work equally well, but key factors set them apart. ...

 * Comparing VMware Horizon vs. Azure Virtual Desktop
   
   Two of the top desktop virtualization technologies are Azure Virtual Desktop
   and Omnissa Horizon -- formerly from VMware. Learn ...

 * About Us
 * Editorial Ethics Policy
 * Meet The Editors
 * Contact Us
 * Advertisers
 * Partner with Us
 * Media Kit
 * Corporate Site

 * Contributors
 * Reprints
 * Answers
 * Definitions
 * E-Products
 * Events
 * Features

 * Guides
 * Opinions
 * Photo Stories
 * Quizzes
 * Tips
 * Tutorials
 * Videos

All Rights Reserved, Copyright 2000 - 2024, TechTarget

Privacy Policy
Cookie Preferences
Cookie Preferences
Do Not Sell or Share My Personal Information


Close