Skip to content

Commit 3075b2f

Browse files
committed
PowerBIPS - Post method for adhoc
PowerBIETL - Wildcard match
1 parent c4fa04a commit 3075b2f

File tree

6 files changed

+60
-39
lines changed

6 files changed

+60
-39
lines changed

.vs/VSWorkspaceState.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ExpandedNodes": [
3+
""
4+
],
5+
"PreviewInSolutionExplorer": false
6+
}

Modules/PowerBIETL/PowerBIETL.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RootModule = 'PowerBIETL.psm1'
55

66
# Version number of this module.
7-
ModuleVersion = '1.3.0.0'
7+
ModuleVersion = '1.3.0.2'
88

99
# ID used to uniquely identify this module
1010
GUID = '80052B99-2AB5-4F9D-842A-03E16B10697D'

Modules/PowerBIETL/PowerBIETL.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Function Export-PBIDesktopToCSV
5959

6060
if ($tables -eq $null -or $tables.Count -eq 0)
6161
{
62-
$modelTables = Invoke-SQLCommand -providerName "System.Data.OleDb" -connectionString $ssasConnStr -executeType "Query" -commandText "select [Name] from `$SYSTEM.TMSCHEMA_TABLES where not [IsHidden]"
62+
$modelTables = Invoke-SQLCommand -providerName "System.Data.OleDb" -connectionString $ssasConnStr -executeType "Query" -commandText "select [Name] from `$SYSTEM.TMSCHEMA_TABLES"
6363

6464
$tables = $modelTables |% {$_.Name}
6565
}
@@ -201,7 +201,7 @@ Function Export-PBIDesktopToSQL
201201

202202
if ($tables -eq $null -or $tables.Count -eq 0)
203203
{
204-
$modelTables = Invoke-SQLCommand -providerName "System.Data.OleDb" -connectionString $ssasConnStr -executeType "Query" -commandText "select [Name] from `$SYSTEM.TMSCHEMA_TABLES where not [IsHidden]"
204+
$modelTables = Invoke-SQLCommand -providerName "System.Data.OleDb" -connectionString $ssasConnStr -executeType "Query" -commandText "select [Name] from `$SYSTEM.TMSCHEMA_TABLES"
205205

206206
$tables = $modelTables |% {$_.Name}
207207
}
@@ -259,7 +259,7 @@ Function Get-PBIDesktopTCPPort
259259

260260
if ($matchedWindows.Count -eq 0)
261261
{
262-
throw "No PBIDesktop window that match '*$pbiDesktopWindowName*'"
262+
throw "No PBIDesktop window that match '$pbiDesktopWindowName'"
263263
}
264264

265265
# Select the first match

Modules/PowerBIPS/PowerBIPS.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ FunctionsToExport = @(
6767
, "Get-PBIImports", "Import-PBIFile"
6868
, "Get-PBIDashboard", "Get-PBIDashboardTile"
6969
, "Get-PBIReport", "Export-PBIReport", "Copy-PBIReports"
70-
, "Get-PBIDatasources"
70+
, "Get-PBIDatasources", "Execute-PBIPost"
7171
)
7272

7373
# Cmdlets to export from this module

Modules/PowerBIPS/PowerBIPS.psm1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,27 @@ Function Get-PBIDatasources{
17741774
Write-Output $result.value
17751775
}
17761776

1777+
Function Execute-PBIPost{
1778+
<#
1779+
.SYNOPSIS
1780+
Gets DataSet connections
1781+
1782+
1783+
#>
1784+
[CmdletBinding()]
1785+
param(
1786+
[Parameter(Mandatory=$false)] [string] $authToken,
1787+
[Parameter(Mandatory=$true)] [string] $uri,
1788+
[Parameter(Mandatory=$true)] [string] $body
1789+
)
1790+
1791+
$authToken = Resolve-PowerBIAuthToken $authToken
1792+
1793+
$headers = Get-PowerBIRequestHeader $authToken
1794+
1795+
Invoke-RestMethod -Uri (Get-PowerBIRequestUrl -scope $uri) -Headers $headers -Method Post -Body ($body)
1796+
1797+
}
17771798

17781799
Function ConvertTo-PBIJson{
17791800
param(

Modules/PowerBIPS/Samples/PowerBIPS.Tests.ps1

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,32 @@ Import-Module "$currentPath\..\PowerBIPS" -Force
88

99
$authToken = Get-PBIAuthToken
1010

11-
$result = Get-PBIModels $authToken
12-
13-
$result | Out-GridView
14-
15-
#$result = Invoke-RestMethod -Uri "https://api.powerbi.com/v1.0/myorg/dashboards" -Headers @{
16-
# 'Content-Type'='application/json'
17-
# 'Authorization'= "Bearer $authToken"
18-
# } -Method Get
19-
#
20-
#$result
21-
22-
return
23-
24-
# -includeTables will include on each DataSet it's tables
25-
26-
$datasets = Get-PBIDataSet -authToken $authToken -name "DataSet1" -includeTables -includeDefinition
27-
28-
$newTableSchema = @{
29-
name = "Table2"
30-
; columns = @(
31-
@{ name = "Id"; dataType = "Int64" }
32-
, @{ name = "Category"; dataType = "String" }
33-
, @{ name = "SubCategory"; dataType = "String" }
34-
, @{ name = "Price"; dataType = "Double" }
35-
, @{ name = "NewPrice"; dataType = "Double" }
36-
)}
37-
38-
# Update the schema of the table with the new column "NewPrice"
39-
40-
Update-PBITableSchema -authToken $authToken -dataSetId "ab77a751-8cd5-4ecd-8260-0a330552d6f0" -table $newTableSchema
41-
42-
# -forceTableSchemaUpdate will always update the schema of the tables
43-
44-
$data | Out-PowerBI -dataSetName "DataSet1" -forceTableSchemaUpdate
11+
$groupId = "f2af64e0-d98b-4b78-aeb1-48a77f0adeeb"
12+
$dsId = "2be32d9a-fa30-4649-97e6-7b3428b9fd68"
13+
14+
Set-PBIGroup -id $groupId
15+
16+
$datasources = Get-PBIDatasources -authToken $authToken -dataSetId $dsId
17+
18+
$bodyStr = "{
19+
""updateDetails"":[
20+
{
21+
""connectionDetails"":
22+
{
23+
""path"": ""\\nas04\private\managers\projectclassification.xlsx"",
24+
},
25+
""datasourceSelector"":
26+
{
27+
""datasourceType"": ""File"",
28+
""connectionDetails"":
29+
{
30+
""path"":""\\nas04\private\managers\project2classification.xlsx""
31+
}
32+
}
33+
}
34+
]
35+
}"
36+
37+
38+
Execute-PBIPost -authToken $authToken -uri "/datasets/$dsId/updatedatasources" -body $bodyStr
4539

0 commit comments

Comments
 (0)