Created
July 18, 2019 11:28
-
-
Save win2000b/913968a4b0d6059242ddf6d1dd8db854 to your computer and use it in GitHub Desktop.
Get All PowerBI Workspaces and the Datasets and What Datasource they use.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login to PowerBI Service | |
Connect-PowerBIServiceAccount | |
# Get all Workspaces from the Organization that start with UK. | |
$UKWorkspaces = Get-PowerBIWorkspace -scope Organization -all | Where-Object {$_.name -like 'uk*'} | |
# For Each Workspace workout the Datasets and the Datasources that correspond to them. | |
foreach ($workspace in $UKWorkspaces) | |
{ | |
$ukdatasets = $workspace | Get-PowerBIDataset -scope Organization | |
foreach ($dataset in $UKdatasets) | |
{ | |
$source=$dataset|Get-PowerBIDatasource -scope Organization | |
$props=[ordered]@{ | |
"WorkSpaceName"=$workspace.Name; | |
"WorkSpaceID"=$workspace.Id; | |
"DatasetName"=$dataset.Name; | |
"DatasetID"=$dataset.Id; | |
"Gateway"=$source.gatewayid; | |
"source"=$source.datasourceid; | |
} | |
$obj=New-Object -TypeName psobject -Property $props | |
Export-Csv -path "c:\temp\dataset.csv" -InputObject $obj -Append -NoTypeInformation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment