Forum Discussion
Anonymous
5 years agoNot applicable
how can i list Workspace and datasets by workspace
hi all, first of all, i am a total beginner (2 days in the learning) i am looking for a good snippet of powershell script that will present workspaces and datatsets like this. note, multiple lines ...
- 5 years ago
Hi Anonymous ,
You must be the Power BI Service administrator.
PBI Service admin can use "Admin portal" feature.
Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lionel-msft
Community Support
5 years agoHi Anonymous ,
Please refer to the code.
Connect-PowerBIServiceAccount
# Variable to receive the codes of the Power BI workspaces
$Workspace = Get-PowerBIWorkspace -All
# Loop for each workspace and for each dataset, get the data from the column below
$DataSets =
ForEach ($workspace in $Workspace)
{
Write-Host $workspace.Name
ForEach ($dataset in (Get-PowerBIDataset -WorkspaceId $workspace.Id))
{
[pscustomobject]@{
WorkspaceName = $Workspace.Name
WorkspaceID = $workspace.Id
DatasetName = $dataset.Name
DatasetID = $dataset.Id
}
}
}
# Defines the directory and name of the file to be exported to the CSV file
$Dir = "C:\Users\lionelch\Desktop\Sampledata\MyWorkspace.csv"
# Exports the result to the CSV file in the directory informed above
$DataSets | Export-Csv $Dir -NoTypeInformation -Encoding UTF8
Disconnect-PowerBIServiceAccount
--My result
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
cateo
2 years agoRegular Visitor
Hi Lionel,
This works for me, but only for workspaces which have datasets in them.
Is it possible to get a list of all workspaces, even though they have no datasets yet?
Thank you in advance!