Skip to main content

setup

Sets up CLI for Microsoft 365 based on your preferences

Usage

m365 setup [options]

Options

--interactive

Configure CLI for Microsoft 365 for interactive use without prompting for additional information.

--scripting

Configure CLI for Microsoft 365 for use in scripts without prompting for additional information.

--skipApp

Skip configuring an Entra app for use with CLI for Microsoft 365.

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

The m365 setup command is a wizard that helps you configure the CLI for Microsoft 365 for your needs. It will ask you a series of questions and based on your answers, it will configure the CLI for Microsoft 365 for you.

The command will ask you the following questions:

  • CLI for Microsoft 365 requires a Microsoft Entra app. Do you want to create a new app registration or use an existing one?

    You can choose between using an existing Entra app or creating a new one. If you choose to create a new app, the CLI will ask you to choose between a minimal and a full set of permissions. It then signs in as Azure CLI to your tenant, creates a new app registration, and stores its information in the CLI configuration.

  • How do you plan to use the CLI?

    You can choose between interactive and scripting use. In interactive mode, the CLI for Microsoft 365 will prompt you for additional information when needed, automatically open links browser, automatically show help on errors. In scripting mode, the CLI will not use interactivity to prevent blocking your scripts.

  • Are you going to use the CLI in PowerShell? (asked only when you chose to configure CLI for scripting)

    To simplify using CLI in PowerShell, you can configure the CLI to output errors to stdout, instead of the default stderr which is tedious to handle in PowerShell.

  • How experienced are you in using the CLI?

    You can choose between beginner and proficient. If you're just starting working with the CLI, it will show you full help information. For more experienced users, it will only show information about commands' options. No matter how you configure this setting, you can always invoke full help by using --help full.

After you answer these questions, the command will build a preset and ask you to confirm using it to configure the CLI.

If you want to configure the CLI on a non-interactive system, or want to configure CLI without answering the questions, you can use the --interactive or --scripting options. When using these options, CLI will apply the correct presets. Additionally, it will detect if it's used in PowerShell and configure CLI accordingly.

The m365 setup command uses the following presets:

  • interactive use:
    • autoOpenLinksInBrowser: true,
    • copyDeviceCodeToClipboard: true,
    • output: 'text',
    • printErrorsAsPlainText: true,
    • prompt: true,
    • showHelpOnFailure: true,
  • scripting use:
    • autoOpenLinksInBrowser: false,
    • copyDeviceCodeToClipboard: false,
    • output: 'json',
    • printErrorsAsPlainText: false,
    • prompt: false,
    • showHelpOnFailure: false,
  • use in PowerShell:
    • errorOutput: 'stdout'
  • beginner:
    • helpMode: 'full'
  • proficient:
    • helpMode: 'options'

Examples

Configure CLI for Microsoft 365 based on your preferences interactively

m365 setup

Configure CLI for Microsoft 365 for interactive use without prompting for additional information

m365 setup --interactive

Configure CLI for Microsoft 365 for use in scripts without prompting for additional information

m365 setup --scripting

Configure CLI for Microsoft 365 without setting up an Entra app

m365 setup --skipApp

Response

The command won't return a response on success.

CTRL + M