Files
oam/knowledge base/m365.md
2023-04-06 18:05:22 +02:00

1.7 KiB

m365

CLI tool for Microsoft 365.

Table of contents

  1. TL:DR
  2. Further readings
  3. Sources

TL:DR

# Installation.
npm install -g '@pnp/cli-microsoft365'
yarn global add '@pnp/cli-microsoft365'
docker run --rm -it 'm365pnp/cli-microsoft365':'latest'

# Disable telemetry.
m365 cli config set -k 'disableTelemetry' -v 'true'

# Login to Microsoft 365.
m365 login -t 'browser'
m365 login --authType 'password' \
  --userName 'user@contoso.com' --password 'pass@word1'
m365 login --authType 'certificate' \
  --certificateFile 'path/to/cert.pfx' --password 'pass@word1'

# Check the current login status.
m365 status

# Send messages to a chat in Teams.
# Specify *only one* of 'chatId', 'chatName' or 'userEmails'.
m365 teams chat message send --chatId 'chat-uuid' -m 'hello world'
m365 teams chat message send --chatName 'chat-display-name' -m 'hello world'
m365 teams chat message send -e 'user-email-1,…,user-email-N' -m 'hello world'
m365 teams chat message send … -m 'hello <b>world</b>'

# Send messages to a channel in Teams.
m365 teams message send -t 'team-uuid' -c 'channel-uuid' -m 'hello world'
m365 teams message send … -m 'hello <b>world</b>'

# Logout.
m365 logout

Further readings

Sources

All the references in the further readings section, plus the following: