FunctionsPublic/New-GraphFolderInRootGroup.ps1
function New-GraphFolderInRootGroup { param([psobject]$accessToken, [string]$groupID, [string]$folderName) # # Create new unified group # $sendBody = @{ "name" = "$($folderName)"; "folder" = @{} } | ConvertTo-Json $sendBody $responseBody = Invoke-RestMethod ` -Uri "https://graph.microsoft.com/v1.0/groups/$($groupID)/drive/root/children" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} ` -Body $sendBody ` -ContentType "application/json" ` -Method POST $jsonResponse = $responseBody | ConvertTo-JSON $createdFolder = ConvertFrom-Json -InputObject $jsonResponse return $createdFolder } |