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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RogerSteinberg
Post Patron
Post Patron

Update parameters through Powershell

Hello,

 

I need help in creating a simple PowerShell script that will update my PBI report parameter.

Body:
{
  "updateDetails": [
    {
      "name": "EndDate",
      "newValue": "2020-06-08"
    },
    {
      "name": "StartDate",
      "newValue": "2020-06-01"
    }
  ]
}

I'm not sure how to followup this code:

Invoke-PowerBIRestMethod -Url "/datasets/datasetID" -Method Post -Body .....

 This is provided by the Microsoft documentation but i'm having trouble putting it into practice

Invoke-PowerBIRestMethod
      -Url <String>
      -Method <PowerBIWebRequestMethod>
      [-Body <String>]
      [-OutFile <String>]
      [-ContentType <String>]
      [-Headers <Hashtable>]
      [-Organization <String>]
      [-Version <String>]
      [<CommonParameters>]

Thank you for your help!

1 ACCEPTED SOLUTION

I found it out:

# Update Parameters URL
$urlUpdateParams = '/datasets/{datasetId}/Default.UpdateParameters'


# Update Parameters Body
$body = '{
  "updateDetails": [
    {
      "name": "EndDate",
      "newValue": "2020-06-14"
    },
    {
      "name": "StartDate",
      "newValue": "2020-06-01"
    }
  ]
}'

$content = 'application/json'

Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method Post -Body $body -ContentType $content # Updates Dataset Parameters

View solution in original post

6 REPLIES 6
lbendlin
Super User
Super User

Your API call is incomplete.

 

https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updateparameters (for regular workspaces)

https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updateparametersingroup (for Premium)

 

Note that you are not updating report parameters. You are updating dataset parameters.

I found it out:

# Update Parameters URL
$urlUpdateParams = '/datasets/{datasetId}/Default.UpdateParameters'


# Update Parameters Body
$body = '{
  "updateDetails": [
    {
      "name": "EndDate",
      "newValue": "2020-06-14"
    },
    {
      "name": "StartDate",
      "newValue": "2020-06-01"
    }
  ]
}'

$content = 'application/json'

Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method Post -Body $body -ContentType $content # Updates Dataset Parameters

Did you run this through Powershell?

yes, after authenticating, for example with Login-PowerBI

I grabbed this script from github. 
https://github.com/microsoft/PowerBI-Developer-Samples/blob/master/PowerShell%20Scripts/Update-Datas... 
I modify the script using my entries.
I run it using Powershell.
No errors are thrown up but the parameters are not changing in the dataset.
Can you please inspect this script please.
I left comments after some of the lines below.
I'm totally new to running commands using Powershell.  I'm trying to learn.
My goal is update the Parameters for a particular dataset.

Write-Host

Connect-PowerBIServiceAccount | Out-Null

$workspaceName = "me"  //for myworkspace, do I use "me", or "My Workpace"?
$datasetName = "dataset123"
$workspaceId = $workspace.Id
$datasetId = $dataset.Id  // is dataset.ID grabbed automatically?

$workspace = Get-PowerBIWorkspace -Name $workspaceName

$dataset = Get-PowerBIDataset | Where-Object Name -eq $datasetName

$workspaceId = $workspace.Id
$datasetId = $dataset.Id

$datasetParametersUrl = "groups/$workspaceId/datasets/$datasetId/Default.UpdateParameters"

$parameterName = "DirectPath_NonOneDrive_JSON"
$newParameterValue = "NewPath"
$postBody = "{updateDetails:[{name:'$parameterName', newValue:'$newParameterValue'}]}"

Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method Post -Body $body -ContentType $content

Thank you.

I authenticated then attempted to run, but does not work for me.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.