-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_monitor_apps.ps1
313 lines (281 loc) · 31.9 KB
/
fix_monitor_apps.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#------------------------------------------------------------------------------------------------------------------------------
#
# Script Name: fix_monitor_apps.ps1
# Description: Reimports Monitoring Apps, recreates Data connections, switches data connections to use certificate auth
# Dependencies: Script most be ran from Central Node as the Qlik Sense Service Account
#
# Version Date Author Change Notes
# 0.1 2018-08-30 Eric Thomas Initial Version
# 0.2 2018-09-23 Added Support for June 2018 Data Connections + Accounts for default password change between versions
# 0.3 2018-10-07 Added Temporary error handling as random Red Text is scary
# 0.4 2018-10-24 Changed Data Connection updates from a 'Find/Replace' to directly updating the JSON Object value
# 0.5 2018-12-13 Updated the handling of Certificates in scenarios where they have already been exported (Script ran previously)
#
# To-Do list: Add FQDN to Archived Logs folder data connection
#
#------------------------------------------------------------------------------------------------------------------------------
#Prepare Connection information
#--------------------------------------
#Build Header
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-Qlik-XrfKey",'NzU0NTIwMDAwNTIy')
$headers.Add("X-Qlik-User",'UserDirectory=internal; UserId=sa_api')
#Obtain Certficate
$cert = Get-ChildItem -Path Cert:\CurrentUser\My | Where {$_.Subject -like '*QlikClient*'}
#$thumbprint = Get-ChildItem -Path cert:\CurrentUser\my | Where {$_.Subject -like '*QlikClient*'}|Select Thumbprint
#$thumbprint = $thumbprint.Thumbprint
#Build FQDN
# Gets the configured hostname from the host.cfg file
$Data = Get-Content C:\ProgramData\Qlik\Sense\Host.cfg
# Convert the base64 encoded install name for Sense to UTF data
$FQDN = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($($Data)))
#Handle TLS 1.2 only environments
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
#Get Password to be used with Certificate
$response = Read-host "Please enter a password that will be used for Client Certificate Authentication" -AsSecureString
$passwordCert = New-Object System.Net.NetworkCredential("Blank",$response)
#Disabling Errors here as Red Text is scary and tells us "The file already exists" or
# that a data connection could not be found
$ErrorActionPreference = "SilentlyContinue"
#Export the Certificate
#--------------------------------------
$certBody = '{
"MachineNames":[
"'+$($FQDN)+'"
],
"certificatePassword":"'+$($passwordCert.Password)+'",
"includeSecretsKey":true,
"exportFormat":"Windows"
}'
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/CertificateDistribution/exportcertificates?xrfkey=NzU0NTIwMDAwNTIy" -Method Post -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $certBody
#Move the Certifcate for the REST Connector
#--------------------------------------
if (Test-Path C:\ProgramData\Qlik\Sense\Engine\Certificates\$($FQDN)) {
Remove-Item -Path C:\ProgramData\Qlik\Sense\Engine\Certificates\$($FQDN) -Recurse -Force
Move-Item -Path C:\ProgramData\Qlik\Sense\Repository\"Exported Certificates"\$($FQDN) -Destination C:\ProgramData\Qlik\Sense\Engine\Certificates\$($FQDN)
} else {
Move-Item -Path C:\ProgramData\Qlik\Sense\Repository\"Exported Certificates"\$($FQDN) -Destination C:\ProgramData\Qlik\Sense\Engine\Certificates\$($FQDN)
}
#Rename Data Connections
#--------------------------------------
#
#Monitor_apps_rest_app
#---------------------------
$RESTapp = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_app')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
#Filter out ID value
$RESTappID = $RESTapp.id
#GET the DataConnection JSON
$RESTappDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
#Modify App Name
$RESTappDC.name = 'monitor_apps_REST_app-old'
#Convert Response to JSON
$RESTappDC = $RESTappDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTappDC
#
#Repeat Through all Monitoring app Data Connections
#
#Monitor_apps_rest_appobject
#---------------------------
$RESTappObject = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_appobject')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTappObjectID = $RESTappObject.id
$RESTappObjectDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappObjectID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTappObjectDC.name = 'monitor_apps_REST_appobject-old'
$RESTappObjectDC = $RESTappObjectDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappObjectID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTappObjectDC
#Monitor_apps_rest_event
#---------------------------
$RESTevent = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_event')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTeventID = $RESTevent.id
$RESTeventDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTeventID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTeventDC.name = 'monitor_apps_REST_event-old'
$RESTeventDC = $RESTeventDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTeventID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTeventDC
#Monitor_apps_rest_license_access
#---------------------------
$RESTLicenseAccess = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_access')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAccessID = $RESTLicenseAccess.id
$RESTLicenseAccessDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAccessID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAccessDC.name = 'monitor_apps_REST_license_access-old'
$RESTLicenseAccessDC = $RESTLicenseAccessDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAccessID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseAccessDC
#Monitor_apps_rest_license_analyzer
#---------------------------
$RESTLicenseAnalyzer = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_analyzer')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAnalyzerID = $RESTLicenseAnalyzer.id
$RESTLicenseAnalyzerDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAnalyzerID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAnalyzerDC.name = 'monitor_apps_REST_license_analyzer-old'
$RESTLicenseAnalyzerDC = $RESTLicenseAnalyzerDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAnalyzerID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseAnalyzerDC
#Monitor_apps_rest_license_login
#---------------------------
$RESTLicenseLogin = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_login')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseLoginID = $RESTLicenseLogin.id
$RESTLicenseLoginDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseLoginID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseLoginDC.name = 'monitor_apps_REST_license_login-old'
$RESTLicenseLoginDC = $RESTLicenseLoginDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseLoginID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseLoginDC
#Monitor_apps_rest_license_overview
#---------------------------
$RESTLicenseOverview = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_overview')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseOverviewID = $RESTLicenseOverview.id
$RESTLicenseOverviewDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseOverviewID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseOverviewDC.name = 'monitor_apps_REST_license_overview-old'
$RESTLicenseOverviewDC = $RESTLicenseOverviewDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseOverviewID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseOverviewDC
#Monitor_apps_rest_license_professional
#---------------------------
$RESTLicenseProfessional = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_professional')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseProfessionalID = $RESTLicenseProfessional.id
$RESTLicenseProfessionalDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseProfessionalID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseProfessionalDC.name = 'monitor_apps_REST_license_professional-old'
$RESTLicenseProfessionalDC = $RESTLicenseProfessionalDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseProfessionalID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseProfessionalDC
#Monitor_apps_rest_license_user
#---------------------------
$RESTLicenseUser = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_user')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseUserID = $RESTLicenseUser.id
$RESTLicenseUserDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseUserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseUserDC.name = 'monitor_apps_REST_license_user-old'
$RESTLicenseUserDC = $RESTLicenseUserDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseUserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseUserDC
#Monitor_apps_rest_task
#---------------------------
$RESTtask = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_task')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTtaskID = $RESTtask.id
$RESTtaskDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTtaskID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTtaskDC.name = 'monitor_apps_REST_task-old'
$RESTtaskDC = $RESTtaskDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTtaskID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTtaskDC
#Monitor_apps_rest_user
#---------------------------
$RESTuser = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_user')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTuserID = $RESTuser.id
$RESTuserDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTuserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTuserDC.name = 'monitor_apps_REST_user-old'
$RESTuserDC = $RESTuserDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTuserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTuserDC
#--------------------------------------
#Upload Operations Monitor
#--------------------------------------
#Build File Path
$fileLocation = $env:ProgramData+"\Qlik\Sense\Repository\DefaultApps\"+"Operations Monitor.qvf"
#Read Data
$FileContent = [IO.File]::ReadAllBytes($fileLocation)
#Perform Upload
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/app/upload?keepData=true&name=Operations+Monitor-New&xrfkey=NzU0NTIwMDAwNTIy" -Method Post -Headers $headers -ContentType 'application/vnd.qlik.sense.app' -Certificate $cert -Body $FileContent
#Upload License Monitor
#--------------------------------------
#Build File Path
$fileLocation = $env:ProgramData+"\Qlik\Sense\Repository\DefaultApps\"+"License Monitor.qvf"
#Read Data
$FileContent = [IO.File]::ReadAllBytes($fileLocation)
#Perform Upload
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/app/upload?keepData=true&name=License+Monitor-New&xrfkey=NzU0NTIwMDAwNTIy" -Method Post -Headers $headers -ContentType 'application/vnd.qlik.sense.app' -Certificate $cert -Body $FileContent
#Swap Data Connections to Cert Auth
#--------------------------------------
#Monitor_apps_rest_app
#---------------------------
$RESTapp = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_app')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
#Filter out ID value
$RESTappID = $RESTapp.id
#GET the DataConnection JSON
$RESTappDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
#Switch Data Connection to Cert Auth
$RESTappDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/app/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTappDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
#Convert Response to JSON
$RESTappDC = $RESTappDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTappDC
#Repeat Through all Monitoring app Data Connections
#
#Monitor_apps_rest_appobject
#---------------------------
$RESTappObject = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_appobject')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTappObjectID = $RESTappObject.id
$RESTappObjectDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappObjectID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTappObjectDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/app/object/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTappObjectDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTappObjectDC = $RESTappObjectDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTappObjectID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTappObjectDC
#Monitor_apps_rest_event
#---------------------------
$RESTevent = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_event')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTeventID = $RESTevent.id
$RESTeventDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTeventID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTeventDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/event/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTeventDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTeventDC = $RESTeventDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTeventID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTeventDC
#Monitor_apps_rest_license_access
#---------------------------
$RESTLicenseAccess = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_access')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAccessID = $RESTLicenseAccess.id
$RESTLicenseAccessDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAccessID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAccessDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/license/accesstypeinfo;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTLicenseAccessDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTLicenseAccessDC = $RESTLicenseAccessDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAccessID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseAccessDC
#Monitor_apps_rest_license_analyzer
#---------------------------
$RESTLicenseAnalyzer = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_analyzer')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAnalyzerID = $RESTLicenseAnalyzer.id
$RESTLicenseAnalyzerDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAnalyzerID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseAnalyzerDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/license/analyzeraccesstype/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTLicenseAnalyzerDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTLicenseAnalyzerDC = $RESTLicenseAnalyzerDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseAnalyzerID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseAnalyzerDC
#Monitor_apps_rest_license_login
#---------------------------
$RESTLicenseLogin = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_login')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseLoginID = $RESTLicenseLogin.id
$RESTLicenseLoginDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseLoginID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseLoginDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/license/loginaccesstype/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTLicenseLoginDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTLicenseLoginDC = $RESTLicenseLoginDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseLoginID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseLoginDC
#Monitor_apps_rest_license_overview
#---------------------------
$RESTLicenseOverview = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_overview')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseOverviewID = $RESTLicenseOverview.id
$RESTLicenseOverviewDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseOverviewID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseOverviewDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/license/accesstypeoverview;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTLicenseOverviewDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTLicenseOverviewDC = $RESTLicenseOverviewDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseOverviewID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseOverviewDC
#Monitor_apps_rest_license_professional
#---------------------------
$RESTLicenseProfessional = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_professional')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseProfessionalID = $RESTLicenseProfessional.id
$RESTLicenseProfessionalDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseProfessionalID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseProfessionalDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/license/professionalaccesstype/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTLicenseProfessionalDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTLicenseProfessionalDC = $RESTLicenseProfessionalDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseProfessionalID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseProfessionalDC
#Monitor_apps_rest_license_user
#---------------------------
$RESTLicenseUser = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_license_user')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseUserID = $RESTLicenseUser.id
$RESTLicenseUserDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseUserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTLicenseUserDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/license/useraccesstype/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTLicenseUserDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTLicenseUserDC = $RESTLicenseUserDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTLicenseUserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTLicenseUserDC
#Monitor_apps_rest_task
#---------------------------
$RESTtask = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_task')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTtaskID = $RESTtask.id
$RESTtaskDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTtaskID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTtaskDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/task/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTtaskDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTtaskDC = $RESTtaskDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTtaskID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTtaskDC
#Monitor_apps_rest_user
#---------------------------
$RESTuser = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/full?filter=(name eq 'monitor_apps_REST_user')&xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTuserID = $RESTuser.id
$RESTuserDC = Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTuserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Get -Headers $headers -ContentType 'application/json' -Certificate $cert
$RESTuserDC.connectionstring = "CUSTOM CONNECT TO 'provider=QvRestConnector.exe;url=https://$($FQDN):4242/qrs/user/full;timeout=999;method=GET;sendExpect100Continue=true;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=true;useCertificate=FromFile;certificateStoreLocation=LocalMachine;certificateStoreName=My;certificateFilePath=$($FQDN)\client.pfx;trustedLocations=qrs_proxy%2https://localhost:4244;queryParameters=xrfkey%20000000000000000;addMissingQueryParametersToFinalRequest=false;queryHeaders=X-Qlik-XrfKey%20000000000000000%1X-Qlik-User%2UserDirectory%%2INTERNAL%%1 %%userid%%2sa_api;PaginationType=None;'"
$RESTuserDC.password = "%%password%2Qlik123!%1certificateKey%2$($passwordCert.Password)%1"
$RESTuserDC = $RESTuserDC | ConvertTo-Json
Invoke-RestMethod -Uri "https://$($FQDN):4242/qrs/dataconnection/$($RESTuserID)?xrfkey=NzU0NTIwMDAwNTIy" -Method Put -Headers $headers -ContentType 'application/json' -Certificate $cert -Body $RESTuserDC
#--------------------------------------