0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OneDrive の「共有ライブラリの作成」を CLI for Microsoft 365 でやってみた

Posted at

OneDrive の「共有ライブラリの作成」を大量に作成する場合、手動でやるのは辛いですよね。そこで CLI for Microsoft 365 を使ってラクをしようと思います。

spo-share-library.png

こちらのドキュメントを参考に、下記の CLI を実行します。

bash
# CLI for Microsoft 365 をインストール
$ npm i -g @pnp/cli-microsoft365

# バージョンを確認
$ m365 version
"v6.4.0"

# ログイン
$ m365 login

# SharePoint の一覧を表示
$ m365 spo site list \
  --output text

# 共有ライブラリ名をセット
$ sharename=infosys-share

# 共有ライブラリを作成
$ m365 spo site add \
  --alias $sharename \
  --title $sharename

# 共有ライブラリのグループ ID を取得
$ gid=$(m365 aad o365group list \
  --mailNickname $sharename \
  --query "[].id" \
  --output text)

# 共有ライブラリのグループメンバー一覧を表示
$ m365 aad o365group user list \
  --groupId $gid \
  --output text

# 共有ライブラリのグループメンバーにユーザーを追加
$ m365 aad o365group user add \
  --groupId $gid \
  --userName test001@example.com

# 共有ライブラリのグループメンバーからユーザーを削除
$ m365 aad o365group user remove \
  --groupId $gid \
  --userName test001@example.com \
  --confirm
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?