为什么"Get-PowerBIDataset" Powershell 命令为我提供工作区中的所有数据集?



我正在从事一些自动化工作。我正在使用命令Power BI Powershell命令。我正在使用的Powershell命令之一是"get - powerbidataset"。当提供数据集名称时,它应该返回数据集ID(即GUID),但它给了我该工作区下的所有数据集。

下面是我在客户端机器上工作的伪代码。工作空间是"WS - abc"其下的数据集为"DS-XYZ";DS-XYZ1"one_answers";DS-XYZ2"。我只需要在命令中提供的数据集名称Id。

#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.

你知道我错过了什么吗?

你需要使用Where-Object:

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

最新更新