We have a lot of data sources listed on our Power BI gateway (~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, obviously very time consuming. 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.
The request body should be as follows;
{"credentialDetails": {"credentialType": "Windows","credentials": "{\"credentialData\":[{\"name\":\"username\", \"value\":\"contoso\\john\"},{\"name\":\"password\", \"value\":\"*****\"}]}","encryptedConnection": "Encrypted","encryptionAlgorithm": "RSA-OAEP","privacyLevel": "Organizational"
}
}
Its the bit in red I cannot create, I can get;
{"credentialDetails": {"encryptedConnection": "Encrypted","privacyLevel": "Organizational","credentialType": "Windows","encryptionAlgorithm": "RSA-OAEP","credentials": "???"
}
}
By using the following PowerShell;
$TEST = [pscustomobject] @{ 'credentialDetails' = @{ credentialType = 'Windows'; credentials = '???'; encryptedConnection = 'Encrypted'; encryptionAlgorithm = 'RSA-OAEP'; privacyLevel = "Organizational" } } | ConvertTo-Json
How do I build in the red text into the PowerShell above, I've tried various things but cannot seem to get the syntax correct.
Thanks