Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Uploading Paginated reports files by Powershell cmdlet or API

Hello Guys

I tried uploading paginated reports by powershell but I haven't find the right command to do it, I've used the following lines to upload datasets and reports but it doesnt work for uploading paginated reports.

 

$datasetsFilenames = Get-ChildItem "C:\Users\jose\Repos\PBI Reports\PaginatedReports\"

$clientsecret="xxxxxxx" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList XXXXXXX, $clientSecret
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId XXXXXXX

foreach ($item in $datasetsFilenames) {
try {
#Call Powerbi APi for Create a Report
$Get = New-PowerBIReport -Path $item.FullName -WorkspaceId XXXXXXX
Write-Host $Get
}
catch [Exception] {
$ErrorMessage = $_.Exception.Message
Write-Host "The DataSets could not be uploaded. The error message was $ErrorMessage"`n -ForegroundColor Red
}
}

 

I've used the previous code to upload datasets and reports through the command " New-PowerBIReport -Path $item.FullName -WorkspaceId XXXXXXX" but I wasn't be able to do it for all my paginated reports.

 

Does anybody know it?

 

Regards.