-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dataset-ListDatasources.ps1
26 lines (15 loc) · 1.04 KB
/
Dataset-ListDatasources.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Requires -Modules @{ ModuleName="MicrosoftPowerBIMgmt"; ModuleVersion="1.2.1026" }
param(
$workspaceId = "cdee92d2-3ff9-43e2-9f71-0916e888ad27",
$datasetId = "33fc0a15-4be2-4f02-85fd-a3f2e9fdec8c"
)
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition -Parent)
try { Get-PowerBIAccessToken | out-null } catch { Connect-PowerBIServiceAccount }
Write-Host "Getting Gateways"
$gateways = Invoke-PowerBIRestMethod -url "gateways" -method Get | ConvertFrom-Json | Select -ExpandProperty value
$datasources = @(Invoke-PowerBIRestMethod -url "groups/$workspaceId/datasets/$datasetId/datasources" -method Get | ConvertFrom-Json | Select -ExpandProperty value)
$datasources | Format-List
$gatewayId = $datasources | select -First 1 -ExpandProperty gatewayId
$datasourcesIdsToMatch = @($datasources.datasourceId)
$gwDatasources = Invoke-PowerBIRestMethod -url "gateways/$gatewayId/datasources" -method Get | ConvertFrom-Json | Select -ExpandProperty value
$gwDatasources |? { $datasourcesIdsToMatch -contains $_.id } | Format-List