1
1
2
2
<# PSScriptInfo
3
3
4
- .VERSION 1.0.0.1
4
+ .VERSION 1.0.0.2
5
5
6
6
.GUID 0b89f8fb-6de5-4f1b-8a0d-6172a89d4743
7
7
41
41
42
42
Param ()
43
43
44
-
45
44
<#
46
45
. SYNOPSIS
47
46
Publishes a Power Bi File to a PowerBi Report Server. It will overwrite existing
48
47
files.
49
48
50
49
. DESCRIPTION
51
- Publishes a Power Bi File to a Power Bi report Server and sets the connection
52
- string for the data source and the credential. Only works with one data source
53
- at present.It will overwrite existing files
50
+ Publishes a Power Bi File to a Power Bi report Server and sets the credential for
51
+ the datasources
54
52
55
53
. PARAMETER FolderName
56
54
The Name of the folder the report is to be placed. Will be created if it doesnt
@@ -69,8 +67,8 @@ The full path to the pbix file
69
67
. PARAMETER Description
70
68
The Description of the report
71
69
72
- . PARAMETER ConnectionString
73
- The connection string for the data source
70
+ . PARAMETER AuthenticationType
71
+ The type of Authentication for the user for the datasource - SQL or Windows
74
72
75
73
. PARAMETER ConnectionUserName
76
74
The User name for the credential for the datasource if required - Use a
@@ -90,15 +88,14 @@ $ReportServerURI = 'http://localhost/Reports'
90
88
$FolderLocation = '/'
91
89
$PBIXFile = 'C:\Temp\test.pbix'
92
90
$Description = "Descriptions"
93
- $ConnectionString = "Server001;dbachecks"
94
91
95
92
$publishPBIXFileSplat = @{
96
93
ReportServerURI = $ReportServerURI
97
94
FolderLocation = $FolderLocation
98
95
Description = $Description
99
96
PBIXFile = $PBIXFile
100
- ConnectionString = $ConnectionString
101
97
FolderName = $FolderName
98
+ AuthenticationType = 'Windows'
102
99
ConnectionUserName = $UserName1
103
100
Secret = $Password1
104
101
@@ -108,13 +105,38 @@ $ConnectionString = "Server001;dbachecks"
108
105
Deploys a report from the PBIX file C:\Temp\test.pbix to the report server
109
106
on the localhost into a folder called TestFolder located at the root of the
110
107
server (which it will create if it doesnt exist) and sets the connection
111
- string to "Server001;dbachecks" with a user name and password stored in the
112
- variables
108
+ string to use a Windows user name and password stored in the variables
109
+
110
+
111
+ . EXAMPLE
112
+
113
+ $FolderName = 'TestFolder'
114
+ $ReportServerURI = 'http://localhost/Reports'
115
+ $FolderLocation = '/'
116
+ $PBIXFile = 'C:\Temp\test.pbix'
117
+ $Description = "Descriptions"
118
+
119
+ $publishPBIXFileSplat = @{
120
+ ReportServerURI = $ReportServerURI
121
+ FolderLocation = $FolderLocation
122
+ Description = $Description
123
+ PBIXFile = $PBIXFile
124
+ FolderName = $FolderName
125
+ AuthenticationType = 'SQL'
126
+ ConnectionUserName = $UserName1
127
+ Secret = $Password1
128
+
129
+ }
130
+ Publish-PBIXFile @publishPBIXFileSplat
131
+
132
+ Deploys a report from the PBIX file C:\Temp\test.pbix to the report server
133
+ on the localhost into a folder called TestFolder located at the root of the
134
+ server (which it will create if it doesnt exist) and sets the connection
135
+ string to use a SQL user name and password stored in the variables
113
136
114
137
. NOTES
115
138
Rob Sewell 20/08/2018
116
139
#>
117
-
118
140
function Publish-PBIXFile {
119
141
[CmdletBinding (DefaultParameterSetName = ' ByUserName' , SupportsShouldProcess )]
120
142
Param (
@@ -129,7 +151,8 @@ function Publish-PBIXFile {
129
151
[Parameter ()]
130
152
[string ]$Description = " Description of Your report Should go here" ,
131
153
[Parameter ()]
132
- [string ]$ConnectionString ,
154
+ [ValidateSet (' Windows' , ' SQL' )]
155
+ [string ]$AuthenticationType ,
133
156
[Parameter (ParameterSetName = ' ByUserName' )]
134
157
[string ]$ConnectionUserName ,
135
158
[Parameter (ParameterSetName = ' ByUserName' )]
@@ -196,9 +219,11 @@ function Publish-PBIXFile {
196
219
197
220
198
221
foreach ($dataSource in $datasources ) {
199
- if ($ConnectionString ) {
200
- # change connection string (to point at new source)
201
- $dataSource.ConnectionString = $ConnectionString
222
+ if ($AuthenticationType -eq ' SQL' ) {
223
+ $dataSource.DataModelDataSource.AuthType = ' UsernamePassword'
224
+ }
225
+ else {
226
+ $dataSource.DataModelDataSource.AuthType = ' Windows'
202
227
}
203
228
if ($Credential -or $UserName ) {
204
229
if ($Credential ) {
@@ -224,4 +249,4 @@ function Publish-PBIXFile {
224
249
Return
225
250
}
226
251
Write-Verbose " Completed Successfully"
227
- }
252
+ }
0 commit comments