FunctionsPublic/Get-GraphDocumentLibraryBySharepointID.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
function Get-GraphDocumentLibraryBySharepointID
{
    param([psobject]$accessToken, [string]$sharePointSiteID)
    #
    # Get Sharepoint site corresponding to group
    #
    $responseBody = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/sites/$($sharePointSiteID)/drive" -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"}
    $jsonResponse = $responseBody | ConvertTo-JSON

    $documentLibrary = ConvertFrom-Json -InputObject $jsonResponse

    return $documentLibrary
}