Graph API Script for channel creation of a SDS created group (powershell)

Adam Cartwright 1 Reputation point
2021-03-26T16:49:47.583+00:00

I have the script below that I thought would work to convert the Office 365 group created in School Data Sync into a education class with the channels as specified.
The script runs in powershell and doesnt error out however nothing actually happens to my groups.
Does anyone have any suggestions or would be able to convert my code into a working example??

$templateBody = {
template@odata.bind = "https://graph.microsoft.com/beta/teamsTemplates('educationClass')";
group@odata.bind = "https://graph.microsoft.com/v1.0/groups('groupID')";
channels[
{
displayName = "Channel 1";
isFavoriteByDefault = true
},
{
displayName = "Channel 2";
membershipType = "private"
},
{
displayName = "Channel 3";
isFavoriteByDefault = true
},
{
displayName = "Channel 4";
isFavoriteByDefault = true
}
]
memberSettings {
allowCreateUpdateChannels = false;
allowDeleteChannels = false;
allowAddRemoveApps = false;
allowCreateUpdateRemoveTabs = false;
allowCreateUpdateRemoveConnectors = false
}
}

$jsonBody = ConvertTo-Json $templateBody

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,550 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,836 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Kartheek Raparthy 1 Reputation point
    2021-04-06T03:04:53.303+00:00

    Please use below graphscript to create channel in team:

    $channelBody =
    '{
    "displayName": "Channel from Graph API",
    "description": "Demo how to make a channel using graph api"
    }'

    $newChannel = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/teams/$($newTeam.id)/channels" -Method POST -Headers $headers -Body $channelBody

    Please go through this link for more information.


  2. Kartheek Raparthy 1 Reputation point
    2021-04-19T04:16:58.52+00:00

    Hi @Adam Cartwright
    You have to loop all by giving input file. keep required information in file.
    $channels = import-csv -path c:******
    foreach($channel in $channels)
    {
    take each value from csv
    excute your script here

    }

    or use manual entry like you did above.

    0 comments No comments