FunctionsPublic/New-GraphFolderInLibrary.ps1
function New-GraphFolderInLibrary { param([psobject]$accessToken, [string]$documentLibraryID, [string]$folderName) $sendBody = @{ "name" = "$($folderName)"; "folder" = @{} } | ConvertTo-Json $sendBody $responseBody = Invoke-RestMethod ` -Uri "https://graph.microsoft.com/v1.0/drives/$($documentLibraryID)/items" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} ` -Body $sendBody ` -ContentType "application/json" ` -Method POST if($null -eq $responseBody) { return $null } else { return $responseBody } } |