From f6266e2541e8b56c2b9d78340cd0e6f379ee6dbd Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 10:00:05 -0600 Subject: [PATCH 1/9] Update bindtogateway.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. --- bindtogateway.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bindtogateway.ps1 b/bindtogateway.ps1 index 6385411..5d19afd 100644 --- a/bindtogateway.ps1 +++ b/bindtogateway.ps1 @@ -46,7 +46,11 @@ 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 + + $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, $platParam) return $authResult } @@ -109,4 +113,4 @@ try { Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription Write-Host "StatusBody:" $responseBody } -} \ No newline at end of file +} From 90b4ec13b73673f42838d78b4e2bfcb33c72af1e Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 10:25:40 -0600 Subject: [PATCH 2/9] Update takeover-dataset.ps1 Neglegted to add the async changes as AcquireToken was deprecated in v3, replaced with AcquireTokenAsync. --- takeover-dataset.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/takeover-dataset.ps1 b/takeover-dataset.ps1 index 5c54d8e..d4d6cb5 100644 --- a/takeover-dataset.ps1 +++ b/takeover-dataset.ps1 @@ -44,7 +44,11 @@ function GetAuthToken $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority - $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto") + $authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, "Auto") + + $authTask.Wait() + + $authResult = $authTask.Result return $authResult } @@ -90,4 +94,4 @@ try { Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription Write-Host "StatusBody:" $responseBody } -} \ No newline at end of file +} From 06e6b1033c054fd9a95bc0f263b98f810e33a1a8 Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 10:29:52 -0600 Subject: [PATCH 3/9] Update takeover-dataset.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. --- takeover-dataset.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/takeover-dataset.ps1 b/takeover-dataset.ps1 index d4d6cb5..a601648 100644 --- a/takeover-dataset.ps1 +++ b/takeover-dataset.ps1 @@ -44,10 +44,14 @@ function GetAuthToken $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority - $authTask = $authContext.AcquireTokenAsync($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 From a4ef8ee6bfb17f1363ae2e906c9461af11c7719e Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 10:30:56 -0600 Subject: [PATCH 4/9] Update bindtogateway.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. --- bindtogateway.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bindtogateway.ps1 b/bindtogateway.ps1 index 5d19afd..6008627 100644 --- a/bindtogateway.ps1 +++ b/bindtogateway.ps1 @@ -47,10 +47,14 @@ function GetAuthToken $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority $promptBehav = [Microsoft.IdentityModel.Clients.ActiveDirectory.PromptBehavior]::Auto - + $platParam = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" -ArgumentList $promptBehav - $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, $platParam) + $authTask = $authContext.AcquireTokenAsync($resourceAppIdURI, $clientId, $redirectUri, $platParam) + + $authTask.Wait() + + $authResult = $authTask.Result return $authResult } From 188f9d4df4e95da5c63654255bbd4941e9674fa2 Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 10:35:45 -0600 Subject: [PATCH 5/9] Update copyWorkspace.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. Made async changes as AcquireToken was deprecated in v3, replaced with AcquireTokenAsync. --- copyWorkspace.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 From 7beee490461f06ca95e09a75a0114218aea2e096 Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 10:37:03 -0600 Subject: [PATCH 6/9] Update manageRefresh.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. Made async changes as AcquireToken was deprecated in v3, replaced with AcquireTokenAsync. --- manageRefresh.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 From f37ed8ec5ce173ced0084ecf48fb00b02640a9bb Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 11:43:06 -0600 Subject: [PATCH 7/9] Update takeover-dataset.ps1 BindToGateway Endpoint has changed and expects the gateway id. Added variables and serialization to handle this. --- takeover-dataset.ps1 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/takeover-dataset.ps1 b/takeover-dataset.ps1 index a601648..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 @@ -75,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() From 000039c5ef191edcbb69449afe30ca55a1a17234 Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 11:46:36 -0600 Subject: [PATCH 8/9] Update rebindReport.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. Made async changes as AcquireToken was deprecated in v3, replaced with AcquireTokenAsync. --- rebindReport.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 From 659631ea75af7e9db369a17d502235e22c7b7f9e Mon Sep 17 00:00:00 2001 From: Keith Lewis Date: Thu, 13 Dec 2018 11:54:16 -0600 Subject: [PATCH 9/9] Update Zero-Downtime-Capacity-Scale.ps1 AcquireToken signature changed in v3 of the ADAL library. Now instead of a string for last parameter, it requires a Platform Parameter Object. Made async changes as AcquireToken was deprecated in v3, replaced with AcquireTokenAsync. --- Zero-Downtime-Capacity-Scale.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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