Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Add requirements for ADAL v3 and updated gateway endpoint to conform to PBI API v2 reqs #25

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Zero-Downtime-Capacity-Scale.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ FUNCTION GetAuthToken
}
ELSE
{
$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, 'Always')
$promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Always

$platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav

$authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam)

$authTask.Wait()

$authResult = $authTask.Result
}

return $authResult
Expand Down
12 changes: 10 additions & 2 deletions bindtogateway.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ function GetAuthToken

$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
$promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto

$platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav

$authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam)

$authTask.Wait()

$authResult = $authTask.Result

return $authResult
}
Expand Down Expand Up @@ -109,4 +117,4 @@ try {
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
Write-Host "StatusBody:" $responseBody
}
}
}
12 changes: 10 additions & 2 deletions copyWorkspace.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ function GetAuthToken

$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
$promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto

$platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav

$authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam)

$authTask.Wait()

$authResult = $authTask.Result

return $authResult
}
Expand Down Expand Up @@ -323,4 +331,4 @@ Foreach ($dashboard in $dashboards) {
}

"Cleaning up temporary files"
Remove-Item -path $temp_path_root -Recurse
Remove-Item -path $temp_path_root -Recurse
14 changes: 11 additions & 3 deletions manageRefresh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ function GetAuthToken
$authority = "https://login.microsoftonline.com/common/oauth2/authorize";

$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")

$promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto

$platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav

$authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam)

$authTask.Wait()

$authResult = $authTask.Result

return $authResult
}
Expand Down Expand Up @@ -75,4 +83,4 @@ Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST –Verbose

# Check the refresh history
$uri = "https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes"
Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET –Verbose
Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET –Verbose
12 changes: 10 additions & 2 deletions rebindReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ function GetAuthToken

$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
$promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto

$platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav

$authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam)

$authTask.Wait()

$authResult = $authTask.Result

return $authResult
}
Expand Down Expand Up @@ -93,4 +101,4 @@ $jsonPostBody = $postParams | ConvertTo-JSON

# Make the request to clone the report
$uri = "https://api.powerbi.com/v1.0/$sourceGroupsPath/reports/$sourceReportId/clone"
Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST -Body $jsonPostBody –Verbose
Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST -Body $jsonPostBody –Verbose
23 changes: 19 additions & 4 deletions takeover-dataset.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

$groupId = " FILL ME IN " # the ID of the group (workspace) that hosts the dataset.
$datasetId = " FILL ME IN " # the ID of dataset to rebind
$gatewayId = " FILL ME IN " # the ID of gateway to bind to

# AAD Client ID
# To get this, go to the following page and follow the steps to provision an app
Expand Down Expand Up @@ -44,7 +45,15 @@ function GetAuthToken

$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority

$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
$promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto

$platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav

$authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam)

$authTask.Wait()

$authResult = $authTask.Result

return $authResult
}
Expand All @@ -67,11 +76,17 @@ if ($groupId -eq "me") {
}

# Make the request to bind to a gateway
$uri = "https://api.powerbi.com/v1.0/$sourceGroupsPath/datasets/$datasetId/BindToGateway"
$uri = "https://api.powerbi.com/v1.0/$sourceGroupsPath/datasets/$datasetId/Default.BindToGateway"

$gatewayObject = @{
gatewayObjectId = $gatewayId
}

$postBodyJson = $gatewayObject | ConvertTo-Json

# Try to bind to a new gateway
try {
Invoke-RestMethod -Uri $uri -Headers $authHeader -Method POST -Verbose
Invoke-RestMethod -Uri $uri -Headers $authHeader -Body $postBodyJson -Method POST -Verbose
} catch {

$result = $_.Exception.Response.GetResponseStream()
Expand All @@ -90,4 +105,4 @@ try {
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
Write-Host "StatusBody:" $responseBody
}
}
}