FunctionsPublic/New-GraphFolderInGroup.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
function New-GraphFolderInGroup { param([psobject]$accessToken, [string]$groupID, [string]$parentItemID, [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/items/$($parentItemID)/children" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} ` -Body $sendBody ` -ContentType "application/json" ` -Method POST if($null -eq $responseBody) { return $null } else { return $responseBody } } |