Powershell iterative command on batches.

%3CLINGO-SUB%20id%3D%22lingo-sub-2271821%22%20slang%3D%22en-US%22%3EPowershell%20iterative%20command%20on%20batches.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2271821%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Folks!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20to%20retrieve%20Dataflow%20based%20on%20Workspace%20as%20per%20below%20PowerShell%20command%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23800000%22%3E%24Workspaces%20%3D%20Get-PowerBIWorkspace%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23800000%22%3E%24res%20%3D%20%40(%20foreach%20(%24workspace%20in%20%24Workspaces)%20%7BGet-PowerBIDataFlow%20-Workspace%20%24workspace%20%7D)%20%7C%20Export-Csv%20-NoTypeInformation%20-Path%20C%3A%5CData%5CDataflow.csv%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20near%20about%205000%20workspace%20to%20pass%20in%20the%20above%20command.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIssue%20-%20This%20command%20breaks%20after%20passing%20200th%20workspace%20to%20the%20script.%3C%2FP%3E%3CP%3ECan%20understand%20the%20failure%20as%20it%20is%20the%20limitation%20of%20PowerShell%20that%20it%20can%20only%20pass%20200%20record%20at%20a%20time.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERequirement%20-%20Is%20it%20possible%20to%20write%20command%20in%20such%20a%20way%20that%20it%20will%20pass%20200%20workspace%20first%20in%20one%20batch%20and%20another%20200%20in%20another%20batch.%3C%2FP%3E%3COL%3E%3CLI%3EIf%20we%20could%20list%20workspace%20ID%E2%80%99s%20and%20batch%20them%20till%20200%20and%20then%20process%20them.%3C%2FLI%3E%3CLI%3ELater%20next%20batch%20condition%20should%20be%20%26gt%3B200%20%26amp%3B%20%26lt%3B%3D%20400%20and%20so%20on%E2%80%A6.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20suggest%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3EAmit%20Srivastava%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2271821%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

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

 

2 Replies

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.

 

 

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