diff --git a/Zero-Downtime-Capacity-Scale.ps1 b/Zero-Downtime-Capacity-Scale.ps1 index 11a334c..fd2ce2f 100644 --- a/Zero-Downtime-Capacity-Scale.ps1 +++ b/Zero-Downtime-Capacity-Scale.ps1 @@ -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 diff --git a/bindtogateway.ps1 b/bindtogateway.ps1 index 6385411..6008627 100644 --- a/bindtogateway.ps1 +++ b/bindtogateway.ps1 @@ -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 } @@ -109,4 +117,4 @@ try { Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription Write-Host "StatusBody:" $responseBody } -} \ No newline at end of file +} diff --git a/copyWorkspace.ps1 b/copyWorkspace.ps1 index 4ef7cae..9218126 100644 --- a/copyWorkspace.ps1 +++ b/copyWorkspace.ps1 @@ -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 } @@ -323,4 +331,4 @@ Foreach ($dashboard in $dashboards) { } "Cleaning up temporary files" -Remove-Item -path $temp_path_root -Recurse \ No newline at end of file +Remove-Item -path $temp_path_root -Recurse diff --git a/manageRefresh.ps1 b/manageRefresh.ps1 index fd8d3b4..f2d000a 100644 --- a/manageRefresh.ps1 +++ b/manageRefresh.ps1 @@ -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 } @@ -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 \ No newline at end of file +Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET –Verbose diff --git a/rebindReport.ps1 b/rebindReport.ps1 index cffc3ba..041e9f1 100644 --- a/rebindReport.ps1 +++ b/rebindReport.ps1 @@ -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 } @@ -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 \ No newline at end of file +Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST -Body $jsonPostBody –Verbose diff --git a/takeover-dataset.ps1 b/takeover-dataset.ps1 index 5c54d8e..8052f22 100644 --- a/takeover-dataset.ps1 +++ b/takeover-dataset.ps1 @@ -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 @@ -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 } @@ -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() @@ -90,4 +105,4 @@ try { Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription Write-Host "StatusBody:" $responseBody } -} \ No newline at end of file +}