Forum Discussion

s2online's avatar
s2online
Regular Visitor
3 years ago

Powershell Get-PowerBIDataflowDatasource Not Returning Data Source Folder Path

 

 

 

 

How can I retrieve the Path property in Powershell for a File or Folder data source? Get-PowerBIDataflowDatasource is not returning the Path property.

The code below shows that Database, Server and Url properties are being returned, but no Path property.

 

 

 

 

$FlowDataSources = Get-PowerBIDataflowDatasource -DataflowId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -Scope Organization

ForEach($datasource in $FlowDataSources) {
    write-host $datasource.DatasourceType
    get-member -inputobject $datasource.connectiondetails | format-table
    }

 

 

 

 

Result (note Folder type but Path property missing):

 

 

 

 

Folder
   TypeName: Microsoft.PowerBI.Common.Api.Shared.DatasourceConnectionDetails

Name        MemberType Definition                    
----        ---------- ----------                    
Equals      Method     bool Equals(System.Object obj)
GetHashCode Method     int GetHashCode()             
GetType     Method     type GetType()                
ToString    Method     string ToString()             
Database    Property   string Database {get;set;}    
Server      Property   string Server {get;set;}      
Url         Property   string Url {get;set;}      

 

 

 

 

 

I know the Path property is set for the data source because I can see it if I call REST directly:

 

 

 

 

invoke-PowerBIRestMethod -Method Get -Url "/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/dataflows/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/datasources" -Verbose

 

 

 

 

Result shows the Path property in the JSON:

 

 

 

 

{
  "@odata.context":"http://wabi-australia-east-a-primary-redirect.analysis.windows.net/v1.0/myorg/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/$metadata#datasources","value":[
    {
      "datasourceType":"Folder","connectionDetails":{
        "path":"\\\\xxx\\xxx\\xxx"
      },"datasourceId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","gatewayId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
  ]
}

 

 

 

 

 

1 Reply

  • Hi s2online​,

    this is a known limitation with the Get-PowerBIDataflowDatasource cmdlet. The underlying DatasourceConnectionDetails object in the PowerShell module just doesn't have a Path property mapped for Folder-type data sources, even though the REST API clearly returns it. Looks like the SDK's object model wasn't updated to cover every property the API can return.

    Since you've already confirmed the REST call gives you what you need, your best bet is to just skip the cmdlet for this specific property and pull it straight from the REST response instead. Something like:

    powershell

    $response = Invoke-PowerBIRestMethod -Method Get -Url "/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/dataflows/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/datasources" $data = $response | ConvertFrom-Json ForEach ($ds in $data.value) { if ($ds.datasourceType -eq "Folder") { Write-Host $ds.connectionDetails.path } }

    This way you get the raw JSON and can pull out path directly, bypassing the cmdlet's incomplete object mapping entirely.

    If you want this fixed properly in the module (not just worked around), it's worth raising it as an issue on the MicrosoftPowerBIMgmt GitHub repo since this seems like a genuine gap in how they're deserializing the connection details.