We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi,
I have to do Synchronous Data Refresh , please help on this
Connect-PowerBIServiceAccount
$token = Get-PowerBIAccessToken -AsString
$Workspace = Get-PowerBIWorkspace -Name 'CitiDriver UAT'
$WorkspaceId = $Workspace.Id
write-host $WorkspaceId
$report = Get-PowerBIReport -WorkspaceId $WorkspaceId -Name ReportName
$reportId = $report
write-host $reportId
$dataset = Get-PowerBIDataset -WorkspaceId $WorkspaceId
$datasetId = $dataset
$token = Get-PowerBIAccessToken -AsString
write-host $token
# Building Rest API header with authorization token
$authHeader = @{
"Authorization"= $token
"Content-Type" = "application/json"
}
$postParams = @{
"datasetId" = "$datasetId"
}
$jsonPostBody = $postParams | ConvertTo-JSON
$u = "https://api.powerbi.com/v1.0/myorg/datasets/8524fac6-699d-4b37-874c-dabb6fd9abf8/refreshes"
$t = Invoke-RestMethod -Uri $u -Method Post -Headers $authHeader -ContentType "application/json" |Out-Null
Start-Sleep -Seconds 600
$result = @()
$uril = "https://api.powerbi.com/v1.0/myorg/datasets/8524fac6-699d-4b37-874c-dabb6fd9abf8/refreshes"
$restResponse1 = Invoke-RestMethod -Uri $uril -Method GET -Headers $authHeader -ContentType "application/json"
$x=$restResponse1.value | Select-Object -First 1
$startime = $x.startTime
$endtime = $x.endTime
$status = $x.status
$props = [ordered]@{
"starttime" = $startime
"endttime" = $endtime
"status" = $status
}
$result += @(New-Object pscustomobject -Property $props)
$outputpath = "C:\output.csv"
$result |Export-Csv -Path $outputpath -NoTypeInformation
$To = "atultiwari.eng06@gmail.com"
$emailconnection = "https://management.azure.com:443/subscriptions/8e1a5828-5178-45ba-a9bf-72616f9c6e06/resourceGroups/C..."
$emailoutput = [PSCustomobject]@{
"TO" = $To
"Subject" = "Powerbi"
"Body" = $result
}
$jsonPostBody = $emailoutput | ConvertTo-Json -Depth 5
Invoke-RestMethod -Uri $emailconnection -Body $jsonPostBody -ContentType 'application/json' -Method Post | Out-Null
Hi @halsa_88 ,
Have trouble to follow.
Please share more details about the Script logic.
Best Regards,
Jay
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 38 | |
| 33 | |
| 16 | |
| 15 |
| User | Count |
|---|---|
| 66 | |
| 63 | |
| 37 | |
| 34 | |
| 22 |