Forum Discussion
Iteration on Powershell
So Get-PowerBIWorkspace will show (by default) the first 100 workspaces your user is assigned to, sso you'll probably want to get all workspaces you're assigned to by calling Get-PowerBIWorkspace -All.
I've not got any PowerBI workspaces that I can get "Get-PowerBIDataFlow" to run on but it apparently returns an object, which can be passed to ConvertTo-Csv, then pipe that to Out-File to stick it in a .csv. So hopefully something like this will do the job:
$workspaces = Get-PowerBIWorkspace -All
foreach ($workspace in $workspaces) {
Get-PowerBIDataFlow -Workspace $workspace | ConvertTo-Csv | Out-File -FilePath "c:\output.csv" -Append
}
If not then you'll have to manipulate the data a bit - not sure what that cmdlet returns so can't say what that would be:
$workspaces = Get-PowerBIWorkspace -All
foreach ($workspace in $workspaces) {
$data = Get-PowerBIDataFlow -Workspace $workspace
#do something with $data to get what you need into a variable called $csv
$csv | Out-File -FilePath "c:\output.csv" -Append
}
Edit: Second attempt... first attempt replied to the wrong post and didn't read the question properly, haha.
- amsrivas28Feb 11, 2021Copper Contributor
CoasterKaty 🙂 🙂
Its works though.:)
Just a little more to ask, I want Workspace ID as well in the output file which is passed to second command.
Will this be possible.
Thanks
Amit
- CoasterKatyFeb 11, 2021MVP
amsrivas28 Should be, if you can get me an example of what
Get-PowerBIDataFlow
returns (as I don't have any PowerBI with data flows set up to try it with) I'll probably be able to put some code together.
- amsrivas28Feb 15, 2021Copper Contributor
Post running this - foreach ($workspace in $Workspaces) {Get-PowerBIDataFlow -Workspace $workspace}
I am getting below details
Id : 744b66d7-ce33-47v1-89fe-a3b4r944fdd4
Name : Dataflow Name
Description :
ModelUrl :
ConfiguredBy : mailto:abc2@abc.comI want to include Workspace Id which i have passed to $Workspace above {Get-PowerBIDataFlow -Workspace $workspace} as part of the output
Please suggest
Amit