山口屋~活動日誌~

私生活で主な出来事をピックアップ

タブ Teams PowerShell teamsAppId Viva Engage

2024-03-10 17:35:55 | パソコン
Teams タブを PowerShell で制御しようというもの。いいサンプルがなくてなかなか大変だった。

グループ一覧を取得してチームIDを確認。
Get-UnifiedGroup | Select-Object DisplayName,ExternalDirectoryObjectId

チャンネル一覧やタブ一覧の確認。
<チャンネル一覧の確認>
Get-MgBetaTeamChannel -TeamId $ExternalDirectoryObjectId
<タブ一覧の確認>
Get-MgBetaTeamChannelTab -TeamId $ExternalDirectoryObjectId -ChannelId $Id
<余談>
Get-MgBetaTeamPrimaryChannel や Get-MgBetaTeamPrimaryChannelTab というのもあるが未確認。

ここから先のタブ操作がサンプルが少なくて難産だった。

Webサイトのタブ追加処理
github.com:Help with adding a tab Issue - #1287
EUC365:Create A Microsoft Team With Graph API And PowerShell
configuration 内の ContentUrl と WebsiteUrl は両方指定しておかないとタブが上手く開かなかった。
$params = @{displayName = "My Web Tab"; "teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/com.microsoft.teamspace.tab.web"; configuration = @{ContentUrl = "https://bing.com";WebsiteUrl = "https://bing.com"}}
New-MgBetaTeamChannelTab -TeamId $ExternalDirectoryObjectId -ChannelId $Id -BodyParameter $params

アプリのタブ追加処理
Microsoft Learn:Configure the built-in tab types in Microsoft Teams
上記のページに記載のないアプリ(Viva Engage とか)はどうすればいいか。Teams向けアプリのID(teamsAppId)を調べるしかない。
Microsoft Learn:Deep linking into Viva Engage
Teams向けアプリを開くリンクは下記の構文なのでここから読取。
https://teams.microsoft.com/l/entity/{teamsAppId}/
そうして出来上がった、Viva Engage タブ追加処理。EntityIdを指定しなくてもタブは開いたが、WebUrlの値がユーザー操作の追加よりも短くなっていたので、EntityIdは指定したほうが無難。
$params = @{displayName = "My Viva Engage"; "teamsApp@odata.bind" = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/db5e5970-212f-477f-a3fc-2227dc7782bf"; configuration = @{WebsiteUrl="https://www.yammer.com";ContentUrl = "https://web.yammer.com/teams/groups/{※}?client=teams";EntityId="https://web.yammer.com/teams/groups/{※}?client=teams"}}
New-MgBetaTeamChannelTab -TeamId $ExternalDirectoryObjectId -ChannelId $Id -BodyParameter $params
※encode {"_type":"Group","id":"$feedId"} into Base64 format without padding
※Office 365 for IT Pros:Creating Viva Engage Communities with the Graph API

Viva Engage(旧 Yammer)のコミュニティサイトURLからfeefidを取得してTeamsタブ向けURLに変換
$ServiceEndpointUri = "Yammer.FeedURL:https://www.yammer.com/{domain}/#/threads/inGroup?type=in_group&feedId={feedId}"
# 正規表現のクエスチョンはエスケープ
$RegularExpression = '^Yammer.FeedURL:https://www.yammer.com/{domain}/#/threads/inGroup\?type=in_group&feedId=(.*)$'
"https://web.yammer.com/teams/groups/" + [Convert]::ToBase64String(([System.Text.Encoding]::Default).GetBytes("{""_type"":""Group"",""id"":""" + ($ServiceEndpointUri -replace $RegularExpression,'$1') + """}")).TrimEnd('=') + "?client=teams"

Notes タブの削除
$notesTab = (Get-MgBetaTeamChannelTab -TeamId $ExternalDirectoryObjectId -ChannelId $Id | Where-Object {$_.DisplayName -eq "Notes"})
Remove-MgBetaTeamChannelTab -TeamId $ExternalDirectoryObjectId -ChannelId $Id -TeamsTabId $notesTab.id

主要アプリの teamsAppId
github.com:Start-DSCConfiguration not inputting TeamsAppPermissionPolicy - no error seen - #3373
"0d820ecd-def2-4297-adad-78056cde7c78":OneNote
"1c4340de-2a85-40e5-8eb0-4f295368978b":Power BI
"26bc2873-6023-480c-a11b-76b66605ce8c":Lists
"2a527703-1f6f-4559-a332-d8a7d288cd88":SharePoint
"2e29398f-1131-4d94-b79f-9c7aa1cfb672":Azure DevOps Server
"4c4ec2e8-4a2c-4bce-8d8f-00fc664a4e5b":Bookings
"57e078b5-6c0e-44a1-a83f-45f75b030d4a":Viva Insights
"7299542a-1697-4ec1-812b-6b70065c0795":Azure Boards
"81fef3a6-72aa-4648-a763-de824aeafb7d":Microsoft Forms
"a6b63365-31a4-4f43-92ec-710b71557af9":Power Apps
"b4f7d39f-ddc7-4f7e-b320-4344444c5e0e":Places
"c3a1996d-db0f-4857-a6ea-7aabf0266b00":Workflows
"cd2d8695-bdc9-4d8e-9620-cc963ed81f41":Dynamics 365
"d5c805b6-2882-45d3-8657-c4f27520f184":Images
"d832a33f-28c2-4969-8ad0-4fee681dc5b4":Praise(称賛)
"db5e5970-212f-477f-a3fc-2227dc7782bf":Viva Engage
"f101079c-3162-4ebe-a651-eba617b4be69":Azure Pipelines
"fc057f53-bb6b-4868-9eb8-a93a8a361b71":Azure Repos
"73d49226-b5c0-42f0-b918-acd20e8a22d8":Custom Filters
"com.microsoft.teamspace.tab.planner":Planner
"com.microsoft.teamspace.tab.vsts":Azure DevOps
"com.microsoft.teamspace.tab.web":Web サイト
コメント    この記事についてブログを書く
  • Twitterでシェアする
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« グループ M365 作成 Teams チ... | トップ | Base64 デコード エンコード ... »
最新の画像もっと見る

コメントを投稿

パソコン」カテゴリの最新記事