FunctionsPublic/New-GraphDocumentLibrary.ps1
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 } |