Announcing Microsoft Graph CLI v1.0.0 release candidate, now with beta support

Carol Mbasinge Kigoonya

We’re excited to introduce the Microsoft Graph CLI v1.0.0 release candidate. Following the successful public preview phase, we’ve provided Graph Beta endpoints, and expanded distribution options, including publication on NuGet, introducing new features, and addressing various bugs.

Microsoft Graph CLI v1.0.0 provides convenient methods to access Microsoft Graph API capabilities on any operating system and any shell. Microsoft Graph CLI can be used in a variety of scenarios, from quick one-off tasks to complex automation scripts. It supports a wide range of features, including authentication, data retrieval, and data manipulation.

What’s new?

We are excited to share updates for Microsoft Graph CLI that will enhance your experience and streamline your workflow:

NuGet Availability: Microsoft Graph CLI is now conveniently available on NuGet. You can get started with just a few simple commands for easier installation.

dotnet tool install --global Microsoft.Graph.Cli --prerelease

Microsoft Graph CLI beta support: For those who want to explore the Graph Beta experience, we have good news. The CLI Beta is now accessible through the msgraph-beta-cli GitHub repo. This opens up new possibilities for testing and leveraging cutting-edge features and functionalities.

Header support: We understand the importance of fine-tuning your interactions with Microsoft Graph, and that’s why we’ve introduced comprehensive header support. With the new --headers option, you have more control over your CLI experience. Customize headers as needed to align perfectly with your specific requirements and use cases.

Cross platform support

Microsoft Graph CLI works on any terminal. We recommend:

Installation

Get the CLI from NuGet OR Download the CLI executable or Docker image from GitHub Repo releases assets link: CLI Download. Find platform specific installation details on the CLI Read Me installation steps.

Optional:

Follow the instructions in Register an application for Microsoft identity platform authentication to get an application ID (also known as a client ID).

Replace YOUR_CLIENT_ID with the client ID from your app registration.

Multiple authentication options

The Microsoft Graph CLI supports multiple authentication options to suit different scenarios for both Delegated and App only experiences.

To view supported authentication options, run the following command.

mgc login –help

Delegated authentication options

1. Interactive Browser Authentication

Use this method to authenticate interactively by entering your Microsoft 365 credentials in a web browser.

mgc login –-strategy InteractiveBrowser

2. Device Code Authentication (default auth option)

Use this method if you’re unable to authenticate directly through a web browser and need to authenticate on a separate device.

mgc login -–strategy DeviceCode

App-only authentication options

1. Client Certificate authentication

Supports client certificate login and is used by client application to authenticate itself using a client ID. 

mgc login --strategy ClientCertificate

2. Environment login

Supports both certificate files and client secret using environment variables and is used by client application to authenticate itself using a client ID.

mgc login --strategy Environment

Supported environment variables are:

    • AZURE_TENANT_ID
    • AZURE_CLIENT_ID
    • AZURE_CLIENT_SECRET
    • AZURE_CLIENT_CERTIFICATE_PATH
    • AZURE_CLIENT_CERTIFICATE_PASSWORD
    • AZURE_CLIENT_SEND_CERTIFICATE_CHAIN

Support for multiple output formats

Several output formats are supported using the --output option which can display data as JSON (default), table or text.

Output table format

Screenshot of code, Output table format

Output JSON format

Screenshot of code, output JSON format

You can turn off Indent JSON responses using the --json-no-indent argument for the JSON output formatter.

Screenshot with code showinghow one can turn off Indent JSON responses using the --json-no-indent argument for the JSON output formatter.

Once installed, you can start using the Microsoft Graph CLI to interact with the Microsoft Graph API. Here are some examples of common commands:

  • To check permissions for scopes, add -h to your command to view information that contains documentation links with permissions.

Screenshot of code: Microsoft Graph CLI interacting with the Microsoft Graph API. An examples of common commands: add -h to your command to view information that contains documentation links with permissions.

  • To check logged in user, access the logged in user’s details using:

mgc me get

  • To get information about a specific user, use the `user` command with the user’s ID or email address:

mgc user get --id <user_id>

  • To create a new group, use the `group` command with the desired group name:

mgc group create --name <group_name>

  • To upload a file to OneDrive, use the `drive item` command with the file path and destination drive:

mgc drive item upload --path <file_path> --drive <drive_id>

For a complete list of available commands and options, refer to the CLI documentation. You can also add --debug to your command to get more details on your interactions.

Samples

You can find more samples here (contain sample commands for CMD, PowerShell, and Bash) Microsoft Graph CLI samples

Changelog

This new release also includes bug fixes included in detailed change log here:

v1.0.0-preview2.

  • Added headers support via the –headers option.
  • Fix bug with sites command crashing during parse.

See full change log

v1.0.0-preview1 (Public Preview)

Additional capabilities supported in this release include:

  • Support for JMESPath queries via the --query option

mgc users list --query "value[].{Name: displayName, Email: mail}"

  • Header command options can now be called multiple times. The header values will now be additive.
  • Contains documentation links to API reference.
  • Add automatic page iteration via the –all command option.

Additional resources to help you get started:

  1. Explore the documentation, where you can find how to install the SDK, authenticate, discover which API a command is calling and more.
  2. Use Microsoft Graph Explorer, a tool that lets you make requests and see responses against Microsoft Graph, and which displays corresponding snippets to requests you make.
  3. Visit the Microsoft Graph Dev Center.

Feedback and Bug Reports

We welcome your feedback and bug reports for this release candidate version. If you encounter any issues or have suggestions for improvement, please open an issue on the GitHub repository.

Happy coding!

Follow us on X | @Microsoft365Dev for the latest news and updates.

0 comments

Discussion is closed.

Feedback usabilla icon