Skip to content

Commit e5f4114

Browse files
committed
update dataset credentials
1 parent bc2a1ca commit e5f4114

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Dataset-GetUsersFromDataset.ps1

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#Requires -Modules @{ ModuleName="MicrosoftPowerBIMgmt"; ModuleVersion="1.2.1026" }
2+
3+
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition -Parent)
4+
5+
$datasetId = "33fc0a15-4be2-4f02-85fd-a3f2e9fdec8c"
6+
7+
Connect-PowerBIServiceAccount
8+
9+
$result = Invoke-PowerBIRestMethod -url "admin/datasets/$datasetId/users" -method Get | ConvertFrom-Json | Select -ExpandProperty value
10+
11+
$result

Dataset-UpdateCredentials.ps1

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#Requires -Modules @{ ModuleName="MicrosoftPowerBIMgmt"; ModuleVersion="1.2.1026" }
2+
3+
$ErrorActionPreference = "Stop"
4+
5+
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition -Parent)
6+
7+
$workspaceId = "9f19cb45-1182-4656-82b0-e7a049985835"
8+
$datasetId = "d688fbb7-01ba-4a8c-a9b6-5d1e262bb347"
9+
$username = "sqluser"
10+
$password = "sqluserpwd"
11+
12+
Connect-PowerBIServiceAccount
13+
14+
$datasources = @(Invoke-PowerBIRestMethod -url "groups/$workspaceId/datasets/$datasetId/datasources" -method Get | ConvertFrom-Json | Select -ExpandProperty value)
15+
16+
$datasource = $datasources[0]
17+
18+
$updateDatasourceBodyStr = "{
19+
""credentialDetails"": {
20+
""credentials"": ""{\""credentialData\"":[{\""name\"":\""username\"",\""value\"":\""$username\""},{\""name\"":\""password\"",\""value\"":\""$password\""}]}"",
21+
""credentialType"": ""Basic"",
22+
""encryptedConnection"": ""NotEncrypted"",
23+
""encryptionAlgorithm"": ""None"",
24+
""privacyLevel"": ""None"",
25+
""useCallerAADIdentity"": false
26+
}
27+
}
28+
"
29+
30+
Invoke-PowerBIRestMethod -url "gateways/$($datasource.gatewayId)/datasources/$($datasource.datasourceId)" -method Patch -Body $updateDatasourceBodyStr

0 commit comments

Comments
 (0)