none
Power BI REST API & PowerShell Update Datasource RRS feed

  • Question

  • We have a lot of data sources (~200) and an IS enforced policy to change passwords every 45 days. The current process is for someone to go through these data sources and input the new credentials as and when they change. I want to be able to improve the efficiency of this process by creating a PowerShell script.

     

    I'm using the officially supported Power BI PowerShell module but I'm having difficulty building the Windows version of the -Body for the Invoke-PowerBIRestMethod command. Specifically the encryption of the credentials, highlighted in red below;

     

    {
      "credentialDetails": {
        "credentialType": "Windows",
        "credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"contoso\\john\"},{\"name\":\"password\", \"value\":\"*****\"}]}",
        "encryptedConnection": "Encrypted",
        "encryptionAlgorithm": "RSA-OAEP",
        "privacyLevel": "Organizational"
      }
    }

    MS have provided documentation on how to achieve this but its written in C#. Is there anyway to integrate this code into a PowerShell script or is there a way to encrypt the string with RSA-OAEP encryption natively in PowerShell?

    • Moved by jrv Monday, September 2, 2019 10:44 AM Better forum
    Monday, September 2, 2019 7:46 AM

All replies

  • Hi MCarlisle3,

    Apologies for delay in getting onto this thread. I am trying to repro the scenario you have, will update the thread accordingly if I find anything. 

    Wednesday, September 11, 2019 3:45 PM
    Owner
  • Thanks, any help would be greatly appreciated.
    Saturday, September 14, 2019 10:33 AM
  • Hi MCarlisle3,

    I am really sorry for delayed response on this. Based on my initial analysis it seems that we do not have any out of box PowerShell commands for encrypting the credentials applicable to Invoke-PowerBIRestMethod. You can check if an option to invoke C# code from PowerShell is something feasible with the c# snippet already documented.

    I am also reaching out to our internal teams to see if they have any other options to share , will update the thread accordingly. 

    Tuesday, October 1, 2019 12:41 AM
    Owner
  • Hi MCarlisle3,

    I am really sorry for delayed response on this. Based on my initial analysis it seems that we do not have any out of box PowerShell commands for encrypting the credentials applicable to Invoke-PowerBIRestMethod. You can check if an option to invoke C# code from PowerShell is something feasible with the c# snippet already documented.

    I am also reaching out to our internal teams to see if they have any other options to share , will update the thread accordingly. 

    Were you ever able to get a response from them?
    Wednesday, January 8, 2020 4:51 PM