Forum Discussion
dom99
6 years agoAdvocate V
Set Service Principal s Dataset Owner
Hi, I wonder if someone can help me. I need to set an existing dataset to be owned by a service principal but cant seem to manage it. the two options I can see are: 1. Manually set it - c...
- 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
Jayendran
6 years agoSolution Sage
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
dom99
6 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 🙂