Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created March 23, 2021 23:03
Show Gist options
  • Save matt40k/7ccb179255b8b15643a9efd5eff63395 to your computer and use it in GitHub Desktop.
Save matt40k/7ccb179255b8b15643a9efd5eff63395 to your computer and use it in GitHub Desktop.
Simple PowerShell script to use the Google Search API to search for public Power BI reports
$apikey = ""
$baseUri = "https://www.googleapis.com/customsearch/v1"
$cx = ""
$query = "site:https://app.powerbi.com"
function GetSearchResults([string]$start)
{
$uri = "$($baseUri)?key=$($apikey)&cx=$($cx)&q=$($query)&start=$($start)"
$c = Invoke-WebRequest -Uri $uri -UseBasicParsing -Method Get
$results = $c.Content | ConvertFrom-Json
foreach ($result in $results.items)
{
$reportUri = $($result.link)
if ($reportUri.StartsWith("https://app.powerbi.com/view"))
{
Add-Content -Value $reportUri -Path "urls.csv"
}
}
return $results.queries.nextPage.startIndex
}
[int]$counter = 0
while ($counter -le 1000)
{
$counter = GetSearchResults($counter)
Start-Sleep -Seconds 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment