「東雲 忠太郎」の平凡な日常のできごと

「東雲 忠太郎」の平凡な日常のできごと

2024.02.26
XML
カテゴリ: Graph API


# Microsoft Graph SDK のインストール

Install-Module -Name Microsoft.Graph.Teams


# アプリケーションの認証情報

$clientId = "YOUR_CLIENT_ID"

$clientSecret = "YOUR_CLIENT_SECRET"

$tenantId = "YOUR_TENANT_ID"


# アクセストークンの取得

$accessToken = Get-MgAccessToken -ClientId $clientId -ClientSecret $clientSecret -TenantId $tenantId


if (-not [string]::IsNullOrEmpty($accessToken)) {

    Write-Host "Access Token: $accessToken"


    # 新しいチームの作成

    $teamName = "New Team"

    $teamDescription = "This is a new team created using Teams Graph API"

    $teamVisibility = "private"  # "public" または "private" を選択

    $teamSettings = @{

        MemberSettings = @{

            AllowCreateUpdateChannels = $true

        }

        MessagingSettings = @{

            AllowUserEditMessages = $true

            AllowUserDeleteMessages = $true

        }

        FunSettings = @{

            AllowGiphy = $true

            GiphyContentRating = "strict"

        }

    }


    $teamBody = @{

        DisplayName = $teamName

        Description = $teamDescription

        Visibility = $teamVisibility

        AdditionalData = $teamSettings

    } | ConvertTo-Json


    $createTeamUrl = "https://graph.microsoft.com/v1.0/teams"

    $createTeamResponse = Invoke-RestMethod -Uri $createTeamUrl -Method Post -Headers @{

        Authorization = "Bearer $accessToken"

        'Content-Type' = 'application/json'

    } -Body $teamBody


    if ($createTeamResponse) {

        Write-Host "New team created successfully. Team ID: $($createTeamResponse.id)"

    } else {

        Write-Host "Failed to create new team."

    }

} else {

    Write-Host "Failed to retrieve access token."

}







お気に入りの記事を「いいね!」で応援しよう

Last updated  2024.02.26 03:21:18


【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! -- / --
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x

© Rakuten Group, Inc.
Create a Mobile Website
スマートフォン版を閲覧 | PC版を閲覧
Share by: