question

AdamCartwright-8331 avatar image
0 Votes"
AdamCartwright-8331 asked KartheekRaparthy-6860 answered

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

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

office-teams-app-devmicrosoft-graph-teamworkmicrosoft-graph-education
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Adding right tags/teams to assist

0 Votes 0 ·

Hi @AdamCartwright-8331 , we are checking this internally, will get back to you soon.

0 Votes 0 ·
KartheekRaparthy-6860 avatar image
0 Votes"
KartheekRaparthy-6860 answered AdamCartwright-8331 edited

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.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Would you know how to modify this so it could create multiple channels at once?

Thanks

0 Votes 0 ·
KartheekRaparthy-6860 avatar image
0 Votes"
KartheekRaparthy-6860 answered

Hi @AdamCartwright-8331
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.