Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
SpaneshSingams
Regular Visitor

How to run full refresh of incremental dataset using Powershell?

Hi folks,

I'm currently working on implementing a full refresh for Power BI datasets on a weekly basis, with the goal of overwriting the existing incremental refresh policy. I'm using the XMLA endpoint via PowerShell scripts, I've tried using the PowerBI-Powershell cmdlets, without successfully overwriting the incremental refresh policy.
I'm now trying to use SSAS method, Invoke-ASCmd and Invoke-Processasdatabase commands, but I'm encountering an error (please refer to the attached screenshot for details).

Downgrading libraries, isn't a feasible option in our environment.

Could you please advise on:

  • A reliable workaround to resolve this issue?
  • Or an alternative approach to perform a full dataset refresh that effectively bypasses or overrides the incremental refresh policy?

Appreciate your guidance!

image (2).png

1 ACCEPTED SOLUTION
SpaneshSingams
Regular Visitor

We used ActiveBatch scheduler to trigger this powershell script.
SqlServer library latest version is not compatible use 
Sqlserver = 21.1.18256
Microsoft.Identity.Client - 4.53.0

Microsoft.PowerBImgmt - 1.2.1111
PowerShell - 5.1

For Full dataset refresh add applyrefreshpolicy = 'false' instead of partitions in the xmla body.


Final Script:

param(
    [Parameter(Mandatory = $true)]
    [string]$WorkspaceName,
[Parameter(Mandatory = $true)]
[string]$GroupId,
    [Parameter(Mandatory = $true)]
    [string]$DatasetName
)

# Credentials
$AppId = # Service PRincipal ID
$TenantId = "TenantID"
$ClientSecret = # Secret from Service Principal

# Creating secure string & credential for Application ID and client secret
$PbiSecurePassword = ConvertTo-SecureString $ClientSecret -Force -AsPlainText
$PbiCredential = New-Object Management.Automation.PSCredential($AppId, $PbiSecurePassword)

# Connect to the Power BI Service Account
Write-Output "Connecting to Power BI Service Account..."
Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId -Credential $PbiCredential
Write-Output "Successfully connected to Power BI Service Account"

# Get the Dataset ID of the Target Dataset
Write-Output "Getting datasets for workspace: $GroupId"
$Datasets = Get-PowerBIDataset -WorkspaceId $GroupId
$DatasetId = ($Datasets | Where-Object { $_.Name -eq $DatasetName }).Id.Guid
Write-Output "Dataset ID for $DatasetName : $DatasetId"


# Set execution policy for the session
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

# Define the required SqlServer module version
$requiredVersion = "21.1.18256"

# Check if the required version is installed
if (Get-InstalledModule -Name SqlServer -RequiredVersion $requiredVersion -ErrorAction SilentlyContinue) {
Import-Module SqlServer -RequiredVersion $requiredVersion
Write-Host "Imported SqlServer module version $requiredVersion."
} else {
Write-Error "SqlServer module version $requiredVersion is not installed. Please install it before running this script."
exit 1
}

# Define JSON refresh command as a variable
$jsonRefresh = @"
{
"refresh": {
"type": "full",
"objects": [
{
"database": "Your Dataset",
"table": "Your Table",
"partition": "Your Partition"
}
]
}
}
"@

# Save JSON to a temporary file
$tempJsonPath = "$env:TEMP\refresh_command.json"
$xmlaEndpoint = "powerbi://api.powerbi.com/v1.0/myorg/$WorkspaceName"

# Run the command
try {
Write-Output "Triggering dataset refresh..."

Invoke-ASCmd -Server $xmlaEndpoint -InputFile $tempJsonPath -ServicePrincipal -ApplicationId $AppId -TenantId $TenantId -Credential $PbiCredential
    Write-Output "Successfully triggered a Power BI Dataset Refresh."
}
catch {
    Write-Error "Failed to trigger dataset refresh."
}

 

View solution in original post

11 REPLIES 11
SpaneshSingams
Regular Visitor

We used ActiveBatch scheduler to trigger this powershell script.
SqlServer library latest version is not compatible use 
Sqlserver = 21.1.18256
Microsoft.Identity.Client - 4.53.0

Microsoft.PowerBImgmt - 1.2.1111
PowerShell - 5.1

For Full dataset refresh add applyrefreshpolicy = 'false' instead of partitions in the xmla body.


Final Script:

param(
    [Parameter(Mandatory = $true)]
    [string]$WorkspaceName,
[Parameter(Mandatory = $true)]
[string]$GroupId,
    [Parameter(Mandatory = $true)]
    [string]$DatasetName
)

# Credentials
$AppId = # Service PRincipal ID
$TenantId = "TenantID"
$ClientSecret = # Secret from Service Principal

# Creating secure string & credential for Application ID and client secret
$PbiSecurePassword = ConvertTo-SecureString $ClientSecret -Force -AsPlainText
$PbiCredential = New-Object Management.Automation.PSCredential($AppId, $PbiSecurePassword)

# Connect to the Power BI Service Account
Write-Output "Connecting to Power BI Service Account..."
Connect-PowerBIServiceAccount -ServicePrincipal -TenantId $TenantId -Credential $PbiCredential
Write-Output "Successfully connected to Power BI Service Account"

# Get the Dataset ID of the Target Dataset
Write-Output "Getting datasets for workspace: $GroupId"
$Datasets = Get-PowerBIDataset -WorkspaceId $GroupId
$DatasetId = ($Datasets | Where-Object { $_.Name -eq $DatasetName }).Id.Guid
Write-Output "Dataset ID for $DatasetName : $DatasetId"


# Set execution policy for the session
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

# Define the required SqlServer module version
$requiredVersion = "21.1.18256"

# Check if the required version is installed
if (Get-InstalledModule -Name SqlServer -RequiredVersion $requiredVersion -ErrorAction SilentlyContinue) {
Import-Module SqlServer -RequiredVersion $requiredVersion
Write-Host "Imported SqlServer module version $requiredVersion."
} else {
Write-Error "SqlServer module version $requiredVersion is not installed. Please install it before running this script."
exit 1
}

# Define JSON refresh command as a variable
$jsonRefresh = @"
{
"refresh": {
"type": "full",
"objects": [
{
"database": "Your Dataset",
"table": "Your Table",
"partition": "Your Partition"
}
]
}
}
"@

# Save JSON to a temporary file
$tempJsonPath = "$env:TEMP\refresh_command.json"
$xmlaEndpoint = "powerbi://api.powerbi.com/v1.0/myorg/$WorkspaceName"

# Run the command
try {
Write-Output "Triggering dataset refresh..."

Invoke-ASCmd -Server $xmlaEndpoint -InputFile $tempJsonPath -ServicePrincipal -ApplicationId $AppId -TenantId $TenantId -Credential $PbiCredential
    Write-Output "Successfully triggered a Power BI Dataset Refresh."
}
catch {
    Write-Error "Failed to trigger dataset refresh."
}

 

v-kathullac
Community Support
Community Support

Hi @SpaneshSingams ,

 

we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

Regards,

Chaithanya

v-kathullac
Community Support
Community Support

Hi @SpaneshSingams ,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

 

Can you check with below steps to resolve your issue.

  1. Register an Azure AD App (service principal) in the Azure portal.
  2. Assign Power BI API permissions: Dataset.ReadWrite.All.
  3. Generate and save Client ID, Client Secret, and Tenant ID.
  4. Ensure the app or user has access to the Power BI workspace and dataset.
  5. Use PowerShell script to authenticate and trigger a full dataset refresh using Power BI REST API.
  6. Script sends a POST request to: https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/datasets/{datasetId}/refreshes
  7. Schedule the PowerShell script using Windows Task Scheduler or Azure Automation to run weekly (e.g., Sunday morning).
  8. This ensures a full refresh captures changes outside the incremental range.
# Define parameters
$clientId = "YOUR_CLIENT_ID"
$clientSecret = "YOUR_CLIENT_SECRET"
$tenantId = "YOUR_TENANT_ID"
$groupId = "WORKSPACE_ID"  # Power BI Workspace ID
$datasetId = "DATASET_ID"  # Power BI Dataset ID

# Get auth token
$body = @{
    grant_type    = "client_credentials"
    client_id     = $clientId
    client_secret = $clientSecret
    scope         = "https://analysis.windows.net/powerbi/api/.default"
}

$tokenResponse = Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" -Body $body
$token = $tokenResponse.access_token

# Trigger full refresh
$refreshUrl = "https://api.powerbi.com/v1.0/myorg/groups/$groupId/datasets/$datasetId/refreshes"
$refreshBody = @{
    notifyOption = "MailOnFailure"
    type = "Full"
} | ConvertTo-Json

Invoke-RestMethod -Method Post -Uri $refreshUrl -Headers @{Authorization = "Bearer $token"} -Body $refreshBody -ContentType "application/json"

Write-Output "Full refresh triggered successfully."

 

Regards,

Chaithanya.

RestAPI method doesn't bypass the incremental policy setup, we tried using this but endup with no success.
Analysis service XMLA Endpoint is the only way to bypass incremental setup.

v-kathullac
Community Support
Community Support

Hi @SpaneshSingams ,

we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

Regards,

Chaithanya

sergej_og
Super User
Super User

You can just try to publish your sematic model into service (again).
The initial load of the model shoulb be triggered doing this. The next refresh should go incremental again.

Regards

We are trying to automate the process, every weekend it gonna trigger full refresh.

What about the capability to track data changes?
No option for you in that case?
You will need another date (maybe datatime) column where Service is looking at.

So you can avoid the full refresh.
But we don't know your setup

Our incremental setup captures modified data within a defined date range over a specific period. However, if changes occur outside of that range, a full dataset refresh becomes necessary to ensure data accuracy. To address this, we plan to automate a full data refresh every weekend using PowerShell.

Deku
Super User
Super User

You would be best off calling the enhanced refresh API, specifying a "full" refresh on any table with incremental refresh on it. This is reload data into archived partitions


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

We tried that too, but only picking incremental tables and partitions. Not bypassing the policy.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.