Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
95 | |
77 | |
65 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |