graph api -iterate

Brass Contributor

Hi, 

I have a CSV file  for  bulk team creation, 

How can I do it using graph API 

 

$tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantID/oauth2/v2.0/token" -Method POST -Body $tokenBody
$headers = @{
"Authorization" = "Bearer $($tokenResponse.access_token)"
"Content-type" = "application/json"
}

write-host $headers.Authorization

#Get Owner ID


$URLOwnwer = "https://graph.microsoft.com/v1.0/users/$Owner"
$ResultOwner = Invoke-RestMethod -Headers $headers -Uri $URLOwnwer -Method Get


#Create Teams

$BodyJsonTeam = @"
{
"template@odata.bind":"https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"displayName":"$TeamName",
"description":"$TeamDescription",
"members":[
{
"@odata.type":"#microsoft.graph.aadUserConversationMember",
"roles":[
"owner"
],
"user@odata.bind":"https://graph.microsoft.com/v1.0/users/$($ResultOwner.id)"
}
]
}
"@
$URLTeam = "https://graph.microsoft.com/v1.0/teams"

Invoke-RestMethod -Headers $headers -Uri $URLTeam -Method POST -Body $BodyJsonTeam

 

Please help 

0 Replies