FunctionsPublic/Find-GraphDocumentLibraryName.ps1
function Find-GraphDocumentLibraryByName { param( [psobject]$accessToken, [string]$sharepointSiteID, [string]$libraryName ) $responseBody = Invoke-RestMethod ` -Uri "https://graph.microsoft.com/v1.0/sites/$($sharepointSiteID)/drives" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} $jsonResponse = $responseBody | ConvertTo-JSON $libraries = ConvertFrom-Json -InputObject $jsonResponse foreach($library in $libraries.value) { if($library.name -eq $libraryName) { return $library } } return $null } |