Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not 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 for a workspace

 

Workspace A workspace A id Dataset x dataset x id
Workspace A workspace A id Dataset y dataset y id
Workspace B workspace B id Dataset z dataset z id

 

 

i wrote this, but it puts everything on one line

$Workspaces = Get-PowerBIWorkspace -Scope Organization -Include All -Filter "tolower(name) eq 'ci workspace'"
$WorkspacesInfo = $Workspaces | Select-Object -Property Name, Id,
@{n="Datasets";e={$_.Datasets.Name -join ', '}},
@{n="DatasetIds";e={$_.Datasets.Id -join ', '}}
$WorkspacesInfo

 

 

i would like the datasets each on their own unique line, along with the workspace they are associated with

 

 

thanks in advance

1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

v-lionel-msft_0-1609123747495.png

You must be the Power BI Service administrator.

PBI Service admin can use "Admin portal" feature.

v-lionel-msft_1-1609123873264.png

 

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.

 

 

View solution in original post

5 REPLIES 5
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

v-lionel-msft_0-1609123747495.png

You must be the Power BI Service administrator.

PBI Service admin can use "Admin portal" feature.

v-lionel-msft_1-1609123873264.png

 

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.

 

 

v-lionel-msft
Community Support
Community Support

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

v-lionel-msft_0-1608789530928.png

 

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.

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!

Anonymous
Not 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.
Anonymous
Not 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
            }
        }
    }

$DataSets

 

 

bear in mind, i am a beginner

cheers

 

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.