Forum Discussion

RogerSteinberg's avatar
RogerSteinberg
Post Patron
6 years ago
Solved

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!

  • 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

6 Replies