Forum Discussion
Iteration on Powershell
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
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
- CoasterKatyFeb 15, 2021MVP
amsrivas28 In theory this should work:
$workspaces = Get-PowerBIWorkspace -All "WorkspaceId,WorkspaceName,Id,Name,Description,ModelUrl,ConfiguredBy" | Out-File -FilePath "c:\output.csv" foreach ($workspace in $workspaces) { $data = Get-PowerBIDataFlow -Workspace $workspace $csv = $workspace.Id.ToString() + "," + $workspace.Name.ToString() + "," + $data.Id.ToString() + "," + $data.Name.ToString() + "," + $data.Description.ToString() + "," + $data.ModelUrl.ToString() + "," + $data.ConfiguredBy.ToString() $csv | Out-File -FilePath "c:\output.csv" -Append }to give you the workspace ID and Name, plus the data from the Get-PowerBIDataFlow cmdlet.
- amsrivas28Feb 17, 2021Copper Contributor
I am getting below error post execution of the provided scripts.
Error :
You cannot call a method on a null-valued expression.
At line:4 char:3
+ $csv = $workspace.Id.ToString() + "," + $workspace.Name.ToString() ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNullPlease suggest!!
Thanks
Amit