FunctionsPublic/New-GraphDocumentLibrary.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 |
function New-GraphDocumentLibrary { param([psobject]$accessToken, [string]$sharepointSiteID, [string]$libraryName, [string]$libraryType = "documentLibrary") # # Create new document library # $sendBody = @{ "displayName" = "$($libraryName)"; "list" = @{ "template"= "$($libraryType)" } } | ConvertTo-Json $sendBody $responseBody = Invoke-RestMethod ` -Uri "https://graph.microsoft.com/v1.0/sites/$($sharepointSiteID)/lists" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} ` -Body $sendBody ` -ContentType "application/json" ` -Method POST $jsonResponse = $responseBody | ConvertTo-JSON $createdDocumentLibrary = ConvertFrom-Json -InputObject $jsonResponse return $createdDocumentLibrary } |