FunctionsPublic/Add-GraphOwnerToGroup.ps1
function Add-GraphOwnerToGroup { param( [psobject]$accessToken, [string]$groupID, [string]$userID ) # # Add Owner to group # $sendBody = @{ "@odata.id"="https://graph.microsoft.com/v1.0/users/$($userID)" } | ConvertTo-Json $responseBody = Invoke-RestMethod ` -Uri "https://graph.microsoft.com/v1.0/groups/$($groupID)/owners/`$ref" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} ` -Body $sendBody ` -ContentType "application/json" ` -Method POST $jsonResponse = $responseBody | ConvertTo-JSON $addOwnerResult = ConvertFrom-Json -InputObject $jsonResponse return $addOwnerResult } |