Forum Discussion
Update parameters through Powershell
- 6 years ago
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
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 ParametersDid you run this through Powershell?
- lbendlin1 year agoSuper User
yes, after authenticating, for example with Login-PowerBI
- roncruiser1 year agoPost Patron
I authenticated then attempted to run, but does not work for me.
- roncruiser1 year agoPost Patron
I grabbed this script from github.
https://github.com/microsoft/PowerBI-Developer-Samples/blob/master/PowerShell%20Scripts/Update-Dataset-Parameters.ps1
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-HostConnect-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.