Skip to content

Commit fe743c7

Browse files
authored
Merge pull request microsoft#270 from Melnikov37/v-mameln/AddQueryTimeoutParametor
Added QueryTimeout parameter for Set-RsDatabase function
2 parents d4cf298 + 3b1d3b4 commit fe743c7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ReportingServicesTools/Functions/Admin/Set-RsDatabase.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ function Set-RsDatabase
6464
This credential is used for *setup* only; it is not used for PowerBI Report Server during runtime.
6565
Note: This parameter will be ignored whenever AdminDatabaseCredentialType is set to Service Account!
6666
67+
.PARAMETER QueryTimeout
68+
Specify how many seconds the query will be running before exit by timeout. Default value is 30.
69+
6770
.EXAMPLE
6871
Set-RsDatabase -DatabaseServerName localhost -Name ReportServer -DatabaseCredentialType ServiceAccount
6972
Description
@@ -120,7 +123,10 @@ function Set-RsDatabase
120123
$ComputerName,
121124

122125
[System.Management.Automation.PSCredential]
123-
$Credential
126+
$Credential,
127+
128+
[int]
129+
$QueryTimeout = 30
124130
)
125131

126132
if ($PSCmdlet.ShouldProcess((Get-ShouldProcessTargetWmi -BoundParameters $PSBoundParameters), "Configure to use $DatabaseServerName as database, using $DatabaseCredentialType runtime authentication and $AdminDatabaseCredentialType setup authentication"))
@@ -198,11 +204,11 @@ function Set-RsDatabase
198204
{
199205
if ($isSQLAdminAccount)
200206
{
201-
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -ErrorAction Stop -Username $adminUsername -Password $adminPassword
207+
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -QueryTimeout $QueryTimeout -ErrorAction Stop -Username $adminUsername -Password $adminPassword
202208
}
203209
else
204210
{
205-
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -ErrorAction Stop
211+
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -QueryTimeout $QueryTimeout -ErrorAction Stop
206212
}
207213
}
208214
catch
@@ -236,11 +242,11 @@ function Set-RsDatabase
236242
{
237243
if ($isSQLAdminAccount)
238244
{
239-
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -ErrorAction Stop -Username $adminUsername -Password $adminPassword
245+
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -QueryTimeout $QueryTimeout -ErrorAction Stop -Username $adminUsername -Password $adminPassword
240246
}
241247
else
242248
{
243-
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -ErrorAction Stop
249+
Invoke-Sqlcmd -ServerInstance $DatabaseServerName -Query $SQLScript -QueryTimeout $QueryTimeout -ErrorAction Stop
244250
}
245251
}
246252
catch

0 commit comments

Comments
 (0)