In a previous post I had talked about getting the Graph Site Url for a SharePoint Online site. I noticed I’ve been doing this quite frequently recently so came up with the following snippet to save me time:
1 2 3 4 5 6 7 8 9 10 |
# From a site Url like https://zzz.sharepoint.com/sites/xxx and for a list called yyy in that: $siteName = "xxx" $listName = "yyy" $tenantName = "zzz" $siteId = ((Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/v1.0/sites/$tenantName.sharepoint.com:/sites/$siteName/").id -split ',')[1] $listId = ((Invoke-MgGraphRequest -Uri "https://graph.microsoft.com/v1.0/sites/$siteId/lists").value | ?{ $_.displayName -eq $listName }).id Write-Host "https://graph.microsoft.com/v1.0/sites/$siteId/lists/$listId/items?expand=fields" |