Forum Discussion
Power BI Action: Update Datasource Connection (Operation is not supported for selector #4)
Hi Anonymous
Please see the below answer which might help you
- Anonymous6 years agoNot applicable
I was using the following PowerShell script to update data source connection.
$datasetname="Dashboard Dataset"
$workspacename="REPORT_TEST"
$clientsec = "$(client_secret)" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $env:client_id, $clientsec
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $env:tenant_id
$workspace =Get-PowerBIWorkspace -Name $workspacename
$DatasetResponse=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json
$datasets = $DatasetResponse.value
foreach($dataset in $datasets){
if($dataset.name -eq $datasetname){
$datasetid= $dataset.id;
break;
}
}
$postParams = @{
updateDetails =@(
@{
name="database"
newValue="db-test"
} ,
@{
name="server"
newValue="server-test"
}
)
} | ConvertTo-Json
Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post
$response=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.UpdateParameters" -Method Post -Body $postParams | ConvertFrom-Json
And its giving error
2020-04-13T23:33:46.3600483Z ##[section]Starting: Update parameters for dataset
2020-04-13T23:33:46.3816028Z ==============================================================================
2020-04-13T23:33:46.3816393Z Task : PowerShell
2020-04-13T23:33:46.3816710Z Description : Run a PowerShell script on Linux, macOS, or Windows
2020-04-13T23:33:46.3817021Z Version : 2.165.0
2020-04-13T23:33:46.3817293Z Author : Microsoft Corporation
2020-04-13T23:33:46.3817666Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2020-04-13T23:33:46.3818127Z ==============================================================================
2020-04-13T23:33:47.1929102Z Generating script.
2020-04-13T23:33:47.2347065Z ========================== Starting Command Output ===========================
2020-04-13T23:33:47.2609972Z ##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\236958ca-ebd7-43a5-8876-a6505f0a70ea.ps1'"
2020-04-13T23:33:49.0798312Z
2020-04-13T23:33:49.0799535Z
2020-04-13T23:33:49.0802661Z Environment : Public
2020-04-13T23:33:49.0803552Z TenantId :
2020-04-13T23:33:49.0804332Z ClientId : ***
2020-04-13T23:33:49.0804530Z Password : ********
2020-04-13T23:33:49.0804683Z
2020-04-13T23:33:50.0959876Z WARNING: The Body parameter was null, the request may be invalid when Method parameter is Post.
2020-04-13T23:33:50.4406494Z
2020-04-13T23:33:51.1154649Z Invoke-PowerBIRestMethod : One or more errors occurred.
2020-04-13T23:33:51.1155801Z At D:\a\_temp\236958ca-ebd7-43a5-8876-a6505f0a70ea.ps1:37 char:11
2020-04-13T23:33:51.1156390Z + $response=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/data ...
2020-04-13T23:33:51.1156920Z + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020-04-13T23:33:51.1157537Z + CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIR
2020-04-13T23:33:51.1158077Z estMethod], AggregateException
2020-04-13T23:33:51.1158601Z + FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
2020-04-13T23:33:51.1159039Z
2020-04-13T23:33:51.1505339Z
2020-04-13T23:33:51.1505696Z
2020-04-13T23:33:51.1984740Z ##[section]Finishing: Update parameters for dataset