I have an azure devops cicd pipeline in which i want to update credential for sharepoint in parameters i have 2 params one sql credential and one for sharepoint i have below script for sql credentials it is working well
Install-Module -Name MicrosoftPowerBIMgmt -Force -Scope CurrentUser
Write-Host
$applicationId = "$(appid)"
$securePassword = "$(clientsecret-value)" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $applicationId, $securePassword
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId "$(TenantID)"
# update these parameters for target workspace and dataset
$datasetName = $(datasetConfigdev)
$datasetnames = $datasetName
foreach($datasetname in $datasetnames){
echo "---"
echo "datasetname : $datasetname"
$workspaceName = $(workspacenamedev)
$dataset_Name = $datasetname
# add credentials for SQL datasource
$sqlUserName = 'readonly'
$sqlUserPassword = 'mpf2$d#v'
# get object for target workspace
$workspace = Get-PowerBIWorkspace -Name $workspaceName
# get object for new dataset
$dataset = Get-PowerBIDataset -WorkspaceId $workspace.Id | Where-Object Name -eq $dataset_Name
# get object for new SQL datasource
$datasource = Get-PowerBIDatasource -WorkspaceId $workspace.Id -DatasetId $dataset.Id
# parse REST to determine gateway Id and datasource Id
$workspaceId = $workspace.Id
$datasetId = $dataset.Id
$datasourceUrl = "groups/$workspaceId/datasets/$datasetId/datasources"
# execute REST call to determine gateway Id and datasource Id
$datasourcesResult = Invoke-PowerBIRestMethod -Method Get -Url $datasourceUrl | ConvertFrom-Json
# parse REST URL used to patch datasource credentials
$datasource = $datasourcesResult.value[0]
$gatewayId = $datasource.gatewayId
$datasourceId = $datasource.datasourceId
$datasourePatchUrl = "gateways/$gatewayId/datasources/$datasourceId"
# create HTTP request body to patch datasource credentials
$patchBody = @{
"credentialDetails" = @{
"credentials" = "{""credentialData"":[{""name"":""username"",""value"":""$sqlUserName""},{""name"":""password"",""value"":""$sqlUserPassword""}]}"
"credentialType" = "Basic"
"encryptedConnection" = "Encrypted"
"encryptionAlgorithm" = "None"
"privacyLevel" = "Organizational"
}
}
# convert body contents to JSON
$patchBodyJson = ConvertTo-Json -InputObject $patchBody -Depth 6 -Compress
# execute PATCH request to set datasource credentials
Invoke-PowerBIRestMethod -Method Patch -Url $datasourePatchUrl -Body $patchBodyJson
# parse REST URL for dataset refresh
#$datasetRefreshUrl = "groups/$workspaceId/datasets/$datasetId/refreshes"
# execute POST to begin dataset refresh
#Invoke-PowerBIRestMethod -Method Post -Url $datasetRefreshUrl -WarningAction Ignore
}
Now i have two params sql and sharepoint i want to authenticate sharepoint data source with OAuth 2.0 credentials how can i pass both credential in one script
Want to pass both sql and sharepoint credential