0

I've been working on a way to retrieve our PowerBI data, and managed to get exactly all the data I'd need to process, however I can't seem to figure out on how to actually parse the data to a proper CSV.

I use the invoke command to get user access to a certain dataset with the below command in PowerShell

Invoke-PowerBIRestMethod -Url 'https://api.powerbi.com/v1.0/myorg/admin/datasets/DATASETID/users' -Method Get

This then comes back with the below response:

{
  "@odata.context":"http://wabi-north-europe-j-primary-redirect.analysis.windows.net/v1.0/myorg/admin/$metadata#Collection(Microsoft.PowerBI.ServiceContracts.Api.
Access.DatasetUser)","value":[
    {
      "datasetUserAccessRight":"ReadWriteReshareExplore","emailAddress":"hiddenemail","displayName":"hiddenname","identifier":"hiddenidentifier","graphId":"hiddengraphid","principalType":"User","userType":"Member"
    },{
      "datasetUserAccessRight":"Read","emailAddress":"hiddenemail","displayName":"hiddenname","identifi
er":"hiddenidentifier","graphId":"hiddengraphid","principalType":"Group"
    }
  ]
}

As shown above it came back with 2 entries of permissions on that dataset, one being a user and the other a group.

I want to parse/export this to a simple CSV file containing the below information:

  • User rights
  • Email address
  • Displayname
  • Identifier
  • Principal Type

How would one achieve this? I've tried several ConvertFrom utilities in PowerShell, but those doesn't seem to work correctly. Is there any easy way to get this to export correctly?

Thank you in advance for any suggestions/advice!

Davyk
  • 1
  • "I've tried several ConvertFrom utilities in PowerShell, but those doesn't seem to work correctly" - `ConvertFrom-Json` is the perfect utility for this job. Can you show us what you attempted (which exact commands did you run?) and describe how the result differs from your expectation :) – Mathias R. Jessen Mar 16 '22 at 14:56
  • Hi @MathiasR.Jessen I've tried running the command for example as `$dataset = (Invoke-PowerBIRestMethod -Url 'urlhere' -Method Get | ConvertFrom-Json)` However this only returns: `@odata.context -------------- http://wabi-north-europe-j-primary-redirect.analysis.windows.net/v1.0/myorg/admin/$metadata#Collection(Microsoft.PowerBI.ServiceContracts.Api.Access.DatasetUser) ` – Davyk Mar 16 '22 at 15:03
  • When converting it to a json however, it returns as below: `"{\r\n \"@odata.context\":\"http://wabi-north-europe-j-primary-redirect.analysis.windows.net/v1.0/myorg/admin/$metadata#Collection(Microsoft.PowerBI.ServiceContr acts.Api.Access.DatasetUser)\",\"value\":[\r\n {\r\n \"datasetUserAccessRight\":\"ReadWriteReshareExplore\",\"emailAddress\":\"hiddenemail .com\",\"displayName\":\"hiddenname\",\"identifier\":\"hiddenidentifier\",\"graphId\":\"hiddengraphid\",\"principalTy pe\":\"User\",\"userType\":\"Member\"\r\n },{\r\n \""` – Davyk Mar 16 '22 at 15:22
  • That's just formatting, hiding the remaining data. `$dataset.value` holds the data you're interested in – Mathias R. Jessen Mar 16 '22 at 15:36

0 Answers0