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?

PowerShellでTeamsのチャネルにSharePointリストのタブを追加する

Last updated at Posted at 2024-12-27

やりたいこと

PowerShellでTeamsのチャネルにSharePointリストのタブを追加したい。

手順

実装方法はMicrosoftの公式ドキュメントに記載してあります。

PowerShell コマンドの全体像

結論、実行コマンドは以下です。

Install-Module Microsoft.Graph -AllowClobber -Scope CurrentUser -Force

Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All"

$teamId = "{チームID}"
$channelId = "{チャネルID}"
$params = @{
    displayName = "{任意の表示名}"
    "teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/2a527703-1f6f-4559-a332-d8a7d288cd88"
    configuration = @{
        contentUrl = "https://{tenant_name}.sharepoint.com/sites/{site_name}/Lists/{list_name}/AllItems.aspx"
        websiteUrl = "https://{tenant_name}.sharepoint.com/sites/{site_name}/Lists/{list_name}/AllItems.aspx"
    }
}

New-MgTeamChannelTab -TeamId $teamId -ChannelId $channelId -BodyParameter $params

Disconnect-MgGraph

各コマンドの説明

Microsoft Graph Teams モジュールをインポートします。これにより、Microsoft Teamsに関するコマンドレットを利用可能になります。

Import-Module Microsoft.Graph.Teams

Microsoft Graph モジュールを現在のユーザーのスコープでインストールします。これにより、Microsoft Graph APIにアクセスするためのコマンドレットが利用可能になります。

Install-Module Microsoft.Graph -Scope CurrentUser

指定されたスコープでMicrosoft Graphに接続します。これにより、ユーザー情報の読み取りやグループの読み書きが可能になります。

Connect-MgGraph -Scopes "User.Read.All", "Group.ReadWrite.All"

対象となるMicrosoft TeamsのチームIDとチャネルIDを設定します。
displayNameにはタブの表示名を設定し、teamsApp@odata.bindにはタブにバインドするアプリのURLを指定します。以下の公式ドキュメントによると、SharePointリストの場合、teamsAppId2a527703-1f6f-4559-a332-d8a7d288cd88です。

また、teamsAppsを取得するコマンドは以下です。

Connect-MgGraph -Scopes "AppCatalog.Read.All"

Get-MgAppCatalogTeamApp

configurationには、タブのコンテンツURLとウェブサイトURLを設定します。

$teamId = "{チームID}"
$channelId = "{チャネルID}"
$params = @{
    displayName = "{任意の表示名}"
    "teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/2a527703-1f6f-4559-a332-d8a7d288cd88"
    configuration = @{
        contentUrl = "https://{tenant_name}.sharepoint.com/sites/{site_name}/Lists/{list_name}/AllItems.aspx"
        websiteUrl = "https://{tenant_name}.sharepoint.com/sites/{site_name}/Lists/{list_name}/AllItems.aspx"
    }
}

指定されたチームのチャネルに新しいタブを追加します。$teamId$channelIdで対象のチームとチャネルを指定し、$paramsでタブの設定を指定します。

New-MgTeamChannelTab -TeamId $teamId -ChannelId $channelId -BodyParameter $params

Microsoft Graphから切断します。

Disconnect-MgGraph
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?