Skip to content

Commit 369c2c7

Browse files
committed
Get Reports
1 parent c3ac44b commit 369c2c7

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

Modules/PowerBIPS/PowerBIPS.psd1

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ FunctionsToExport = @(
6666
, "Add-PBITableRows", "Clear-PBITableRows", "Update-PBITableSchema"
6767
, "Get-PBIImports", "Import-PBIFile"
6868
, "Get-PBIDashboard", "Get-PBIDashboardTile"
69+
, "Get-PBIReport"
6970
)
7071

7172
# Cmdlets to export from this module

Modules/PowerBIPS/PowerBIPS.psm1

+48
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,54 @@ Function Set-PBIGroup{
170170
}
171171
}
172172

173+
Function Get-PBIReport{
174+
<#
175+
.SYNOPSIS
176+
Gets all the PowerBI existing reports and returns as an array of custom objects.
177+
178+
.EXAMPLE
179+
180+
Get-PBIReport -authToken $authToken
181+
182+
#>
183+
[CmdletBinding()]
184+
param(
185+
[Parameter(Mandatory=$false)] [string] $authToken,
186+
[Parameter(Mandatory=$false)] [string] $name,
187+
[Parameter(Mandatory=$false)] [string] $id
188+
)
189+
190+
$authToken = Resolve-PowerBIAuthToken $authToken
191+
192+
$headers = Get-PowerBIRequestHeader $authToken
193+
194+
Write-Verbose "Getting Reports"
195+
196+
$result = Invoke-RestMethod -Uri (Get-PowerBIRequestUrl -scope "reports" -beta) -Headers $headers -Method Get
197+
198+
$reports = $result.value
199+
200+
Write-Verbose "Found $($reports.count) groups."
201+
202+
if (-not [string]::IsNullOrEmpty($name))
203+
{
204+
Write-Verbose "Searching for the dashboard '$name'"
205+
206+
$reports = @($reports |? name -eq $name)
207+
208+
if ($reports.Count -ne 0)
209+
{
210+
Write-Verbose "Found report with name: '$name'"
211+
}
212+
else
213+
{
214+
throw "Cannot find report with name: '$name'"
215+
}
216+
}
217+
218+
Write-Output $reports
219+
}
220+
173221
Function Get-PBIDashboard{
174222
<#
175223
.SYNOPSIS

Modules/PowerBIPS/PowerBIPS.pssproj

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<Compile Include="Samples\CSVData\Sales.201504.csv" />
4646
<Compile Include="Samples\CSVData\Sales.201505.csv" />
4747
<Compile Include="Samples\CSVData\Sales.201506.csv" />
48+
<Compile Include="PowerBIPS.Test.ps1" />
4849
<Compile Include="Samples\PowerBIPS.TwitterRealTime.ps1" />
4950
<Compile Include="Samples\PBIX\MyMovies.pbix" />
5051
<Compile Include="Samples\PowerBIPS.OutPowerBI.ps1" />

0 commit comments

Comments
 (0)