skadam85
skadam85

Reputation: 543

Why does "Get-PowerBIDataset" Powershell command gives me all the datasets in the Workspace?

I am working on some automation. I am using command Power BI Powershell commands. One of the Powershell commands I am using is "Get-PowerBIDataset". It's supposed to return Dataset ID (i.e. GUID) when Dataset name provided but it gives me all the datasets under that workspace.

Below is the pseudo code as I am working on client machine. The workspace is say "WS - ABC" and the Dataset under it are "DS-XYZ", "DS-XYZ1" and "DS-XYZ2". I only want Id for Dataset name provided in the command.

#Connect using Service Principal
Connect-PowerBIServiceAccount -ServicePrincipal ####

#Get Workspace details
$Workspace = Get-PowerBIWorkspace -Name 'WS - ABC'
Write-Output $Workspace.Id ## Works correctly and gives me GUID only for 'WS - ABC'

#Get Dataset details
$Dataset = Get-PowerBIDataset -Name 'DS-XYZ' -WorkspaceId $Workspace.Id
Write-Output $Dataset.Id ## Works incorrectly and gives me GUIDs for all the 3 Datasets in the Workspace.

Any idea what I am missing here?

Upvotes: 0

Views: 1957

Answers (1)

user3438309
user3438309

Reputation: 26

You need to use Where-Object:

$Dataset = Get-PowerBIDataset -WorkspaceId $Workspace.Id | Where-Object {$_.name -eq 'DS-XYZ'}

Upvotes: 1

Related Questions