Forum Discussion
how can i list Workspace and datasets by workspace
- 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.
Hi 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.
- Anonymous5 years agoNot applicable
Hi Lionel
thanks for answering my question
It does not appear to be returning records. i modified it like this too, to see on screen output but nothing.
Note, there is valid data in $Workspace, i ran it on its own in isolation and it output fine
$Workspace = Get-PowerBIWorkspace -All -Scope Organization -ErrorAction SilentlyContinue -Include All ` -Filter "tolower(state) eq 'active' and tolower(type) ne 'personalgroup' and tolower(name) eq 'hexit'" ` | Select-Object Id, Name, Type, State, Description, IsOrphaned # 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 } } } $DataSetsbear in mind, i am a beginner
cheers
- Anonymous5 years agoNot applicable
hi Lionel
could it be because i am running this with -Scope Organization. When running the Get-PowerBIDataset manually i get an error
Get-PowerBIDataset -Scope Organization -WorkspaceId 75036789-685c-40b9-9034-4c4386d8bd1d -Debug DEBUG: 13:01:40 - Get-PowerBIDataset begin processing with ParameterSet List. DEBUG: 13:01:41 - Cmdlet version: 1.0.896.0 Get-PowerBIDataset : A task was canceled. At line:1 char:1 + Get-PowerBIDataset -Scope Organization -WorkspaceId 75036789-685c-40b ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (Microsoft.Power...tPowerBIDataset:GetPowerBIDataset) [Get-PowerBIDataset], TaskCanceledException + FullyQualifiedErrorId : A task was canceled.,Microsoft.PowerBI.Commands.Data.GetPowerBIDataset VERBOSE: Request Uri: https://api.powerbi.com/v1.0/myorg/admin/groups/75036789-685c-40b9-9034-4c4386d8bd1d/datasets VERBOSE: Status Code: 429 (429) VERBOSE: Request Uri: https://api.powerbi.com/v1.0/myorg/admin/groups/75036789-685c-40b9-9034-4c4386d8bd1d/datasets VERBOSE: Status Code: 429 (429) DEBUG: 13:03:28 - Get-PowerBIDataset end processing. - cateo2 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!