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