Forum Discussion
Set Service Principal s Dataset Owner
- 6 years ago
Hi dom99 ,
Using powershell it is possible
I already created the entier script and published here
https://gallery.technet.microsoft.com/AzureDevOps-CICD-for-fefd58b8
The powershell scripts looks like
$applicationId = "" $clientsec = "" | ConvertTo-SecureString -AsPlainText -Force # $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientsec Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "" $workspacename="PowerBI_CICD_PROD" $datasetname="AdventureReports" ##Getworksapce $workspace =Get-PowerBIWorkspace -Name $workspacename # GetDataSets $DatasetResponse=Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets" -Method Get | ConvertFrom-Json # Get DataSet $datasets = $DatasetResponse.value foreach($dataset in $datasets){ if($dataset.name -eq $datasetname){ $datasetid= $dataset.id; break; } } ## Take Over DataSet Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post
Hi Jayendran
I've tried your script but unfortunatly the method below fails.
Invoke-PowerBIRestMethod
I successfully log in as the service principal and assign the values as required, the script works up until the very end.
The error message is:
Invoke-PowerBIRestMethod : One or more errors occurred.
At line:3 char:1
+ Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($da ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIR
estMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
Can you help with finding out why its not working? I found your powershell scripts you'd uploaded, very handy to have thank you.
Hi dom99 ,
- Make sure that SPN have admin access to your Workspace.
- Make sure the workspace id ,datasetid are properly passing to the script
After you got the error run the below script
Resolve-PowerBIError
Which will gives you the exact error
- dom996 years agoAdvocate V
Hi Jayendran
I read the documentation and turns out the -Body parameter (sometimes called the content) is now required for POST operations.
so the invoke method looks like:
Invoke-PowerBIRestMethod -Url "groups/$($workspace.id)/datasets/$($datasetid)/Default.TakeOver" -Method Post -Body ""thanks for your help 🙂