Forum Discussion

amsrivas28's avatar
amsrivas28
Copper Contributor
Apr 14, 2021

Powershell iterative command on batches.

Hi Folks!!

I need to retrieve Dataflow based on Workspace as per below PowerShell command

 

$Workspaces = Get-PowerBIWorkspace

$res = @( foreach ($workspace in $Workspaces) {Get-PowerBIDataFlow -Workspace $workspace }) | Export-Csv -NoTypeInformation -Path C:\Data\Dataflow.csv

I have near about 5000 workspace to pass in the above command.

 

Issue - This command breaks after passing 200th workspace to the script.

Can understand the failure as it is the limitation of PowerShell that it can only pass 200 record at a time.

 

Requirement - Is it possible to write command in such a way that it will pass 200 workspace first in one batch and another 200 in another batch i.e.

  1. If we could list workspace ID’s and batch them till 200 and then process them.
  2. Later next batch condition should be >200 & <= 400 and so on….

 

Please suggest 

Thanks

Amit Srivastava

 

  • AndySvints's avatar
    AndySvints
    Steel Contributor

    Hell amsrivas28,

    Can you please elaborate on what error are you getting when cmdlet breaks?

    There are two possible options to get PowerBI data flow information:

    1) Get all Power BI workspaces along with related reports, dashboards, datasets, dataflows and workbooks within the user's organization:

    Get-PowerBIWorkspace -Scope Organization -Include All

    Reference

    2) Get all Power BI dataflows within a user's organization

    Get-PowerBIDataflow -Scope Organization

     

    Reference

    Hope that helps.

     

     

    • amsrivas28's avatar
      amsrivas28
      Copper Contributor

      Hi AndySvints ,

      I need to retreive data that will have relationship between Workspace and Dataflow that's why i am passing workspaceid into the Dataflow command and later will retreive workspaceid as well alongwith dataflow detail.

       

      I am more than happy if you can suggest any other way to fetch relationship between all the heads such as workspaces, dataset, dataflow report and user.

       

      Thanks

      Amit 

Resources